
you can't use define based solution for switching MT/non MT. It should be template parameter. As of now there is no singleton that can work in presence of threads but without [regard] to
Gennadiy wrote: them.
BOOST_HAS_THREADS is global compile time switch which should have no bearings in design on singleton. regardless of this flag I may or may not want instance construction to be syncronized.
Tobias wrote:
The design doesn't change based on that macro.
Gennadiy wrote:
It does. You either do or don't do syncronization based on it.
Tobias wrote:
Synchronisation with what? In a program with just one thread it's just a no-op.
This has been raised before. I normally write single-threaded code. Occasionally I am forced to write a worker thread to perform a particular function. That means that I need BOOST_HAS_THREADS defined. On the other hand, I /know/ that most of my singletons will only be used by the main thread, so why do I have to pay for synchronization on those singletons? -- Martin Bonner