BoostTest: Is BOOST_MESSAGE is not thread safe?

Guys,
I've just noticed BOOST_MESSAGE is not thread safe instruction.
It is unbelievable!! I do not want to believe it!!!
Try this:
#define BOOST_TEST_MAIN
#include

There was a discussion in the mailing how to make Boost.Test thread-safe. The problem is that Boost.Test needs to be boost-clean, because other libraries such as Boost.Thread etc. use it for testing. Therefore relying on Boost.Thread is not possible in such a case => requires the development of the proprietary thread-safety, synchronization etc. which works on all platforms where Boost.Test runs. On the other hand, not everyone requires thread-safety. Introducing it might slow down the test execution tremendously. So it is up to you how to implement you synchronization mechanisms :( and whether to implement them at all. Regards, Ovanes On Tue, Mar 23, 2010 at 9:28 PM, Dmytro Ovdiienko < dmitriy.ovdienko@gmail.com> wrote:
Guys,
I've just noticed BOOST_MESSAGE is not thread safe instruction. It is unbelievable!! I do not want to believe it!!!
Try this:
#define BOOST_TEST_MAIN #include
#include void foo() { for( size_t i = 0; i < 100000000; ++i ) { BOOST_MESSAGE( "111111122222222223333333333" ); } }
BOOST_AUTO_TEST_CASE( testBoost ) { size_t const SIZE = 2; boost::thread t[ SIZE ];
for( size_t i = 0; i < SIZE; ++i ) { t[ i ] = boost::thread( &foo ); }
for( size_t i = 0; i < SIZE; ++i ) { t[ i ].join(); } }
windows XP SP3 32bit VS 2008 SP1 boost 1.42
-- Dmytro Ovdiienko
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hi Ovanes,
Thank you for reply.
IMHO there is no problem if:
- boost::test depends on boost::thread
- boost::thread has no dependencies
- boost::thread::test depends on: boost::test + boost::thread
As for locking on my side. It will be really slow if I will lock every
statement. Actually locking is needed only when code needs to write to the
stream. If test expression is ok, no locking should be performed.
On test performance, if you need good performance in test, remove
BOOST_MESSAGE. Also in singe thread test application locking will
not dramatically affect performance.
On 24 March 2010 12:21, Ovanes Markarian
There was a discussion in the mailing how to make Boost.Test thread-safe. The problem is that Boost.Test needs to be boost-clean, because other libraries such as Boost.Thread etc. use it for testing. Therefore relying on Boost.Thread is not possible in such a case => requires the development of the proprietary thread-safety, synchronization etc. which works on all platforms where Boost.Test runs. On the other hand, not everyone requires thread-safety. Introducing it might slow down the test execution tremendously. So it is up to you how to implement you synchronization mechanisms :( and whether to implement them at all.
Regards, Ovanes
On Tue, Mar 23, 2010 at 9:28 PM, Dmytro Ovdiienko < dmitriy.ovdienko@gmail.com> wrote:
Guys,
I've just noticed BOOST_MESSAGE is not thread safe instruction. It is unbelievable!! I do not want to believe it!!!
Try this:
#define BOOST_TEST_MAIN #include
#include void foo() { for( size_t i = 0; i < 100000000; ++i ) { BOOST_MESSAGE( "111111122222222223333333333" ); } }
BOOST_AUTO_TEST_CASE( testBoost ) { size_t const SIZE = 2; boost::thread t[ SIZE ];
for( size_t i = 0; i < SIZE; ++i ) { t[ i ] = boost::thread( &foo ); }
for( size_t i = 0; i < SIZE; ++i ) { t[ i ].join(); } }
windows XP SP3 32bit VS 2008 SP1 boost 1.42
-- Dmytro Ovdiienko
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- Dmytro Ovdiienko e-mail: dmitriy.ovdienko@gmail.com skype: dmitriy.ovdienko@gmail.com mobile: +38050-1909731

On Wed, Mar 24, 2010 at 11:41 AM, Dmytro Ovdiienko < dmitriy.ovdienko@gmail.com> wrote:
Hi Ovanes,
Thank you for reply.
IMHO there is no problem if:
- boost::test depends on boost::thread - boost::thread has no dependencies - boost::thread::test depends on: boost::test + boost::thread
The problem is that Boost.Thread uses Boost.Test for tests. And that would have a cyclic dependency inside boost :( Furthermore, if Boost.Thread breaks it will break Boost.Test as well and it is unclear how such cyclically dependent tests are going to resolve such issues than.

Dmytro Ovdiienko
Hi Ovanes,
Thank you for reply.
IMHO there is no problem if:
- boost::test depends on boost::thread - boost::thread has no dependencies - boost::thread::test depends on: boost::test + boost::thread
Feel free to submit patch. All the changes should be protected by BOOST_TEST_THREAD_SAFE. Gennadiy
participants (3)
-
Dmytro Ovdiienko
-
Gennadiy Rozental
-
Ovanes Markarian