|
Boost Users : |
Subject: Re: [Boost-users] BoostTest: Is BOOST_MESSAGE is not thread safe?
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2010-03-24 06:21:00
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_at_[hidden]> 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 <boost/test/unit_test.hpp>
> #include <boost/thread/thread.hpp>
>
> 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_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net