From: Steve Hutton (shutton_at_[hidden])
Date: 2003-08-26 23:23:42
In article <uznhwgzti.fsf_at_[hidden]>, David Abrahams wrote:
> "Neal D. Becker" <nbecker_at_[hidden]> writes:
>> On Saturday 23 August 2003 07:18 am, John Maddock wrote:
>>> > One more thing: what exactly can go wrong with 1.30.0 if
>>> > -pthread isn't used? Is it boost specific or a general thing
>>> > (e.g. issues w/ respect to libstdc++)?
>>> A general thing - without this then:
>>> Your std lib is not thread safe.
>>> Your C lib is not thread safe.
>>> g++ will not emit thread safe exception handling code.
>>> Thus while for C programs enabling thread support is just a question of
>>> linking to the right libraries, for C++ you also need to ensure that the
>>> compiler "knows" that you want thread safe code.
>> You mean I can't just run bjam with no options and get the libs built with
>> thread support? I need to add a command-line option?
> The libraries that require thread support will be built with thread
> support. The others will not, unless <threading>multi has been placed
> in their default-build settings; <threading>single is the global
I recently ran into this trying to use shared_ptr in a mulithreaded app.
The docs might be somewhat incomplete with regard to this. e.g.
"preparing to use Boost in a development project is relatively
straightforward. Most boost libraries are implemented entirely within
their header files. The only preparation for their use is to add the
boost root directory to your compiler's list of #include<...> search paths."
"shared_ptr uses Boost.Config to detect whether the implementation supports
threads. If your program is single-threaded, but your platform is autodetected
by Boost.Config as supporting multiple threads, #define BOOST_DISABLE_THREADS
to eliminate the thread safety overhead."
It wasn't immediately clear to me how to ensure that the linux app I am
writing will always use the threadsafe version of shared_ptr (my app requires
pthreads), no matter how/if the user configured boost. What I ended up doing
was verifying pthread support at install time, and then defining
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk