From: Peter Dimov (pdimov_at_[hidden])
Date: 2004-04-22 11:07:20
Carl Daniel wrote:
> Playing with a Spirit-based parser for a simple scripting language I
> noticed that #defining BOOST_DISABLE_THREADS resulted in a parser
> that was nearly 3 times faster. For reasons that aren't relevant to
> the discussion, this had to be an MT build, but the parser didn't
> need thread safety.
> That made me wonder though: If I #define BOOST_DISABLE_THREADS in
> some translation units but not in others, what's going to happen?
In theory? Undefined behavior because of ODR violations.
In practice, on Windows the current version will mostly work "as expected"
(but earlier versions deadlocked).
> I suppose one way of summarizing it is this: does BOOST_DISABLE_THREADS
> change the type of shared_ptr that's made?
No, it does not.
> If not, that seems like a rather serious
> problem to me - especially given the enormous difference in
> performance that I measured (optimized build with VC8 alpha).
> What obvious thing am I overlooking?
Nothing. The implementation of shared_ptr needs a serious redesign WRT
thread safety, which is planned but requires free time on my part, which is
currently in short supply, although I've got some ordered.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk