
Hello Robert, Wednesday, August 22, 2007, 12:43:03 AM, you wrote:
Tobias Schwinger wrote:
AFAICT, our "lightweight toolbox" is still insufficient to implement a thread-safe Singleton - I might be missing something, though. How would you initialize 'lightweight_mutex' when you can't know that ctors are run in static context (as within a shared library)?
Maybe it's possible to make 'detail::atomic_count' an aggregate and provide a macro for initialization (just as pthread does for its synchronization primitives). Then it would be trivial to implement a 'lightweight_once' on top of it...
Please start thinking about this. I don't see why this can't be a header only library. Of course in my case, the expanded headers (instantiated code) will be compiled into the serializatoin library as an implementation detail. I would much prefer that to having to link in another library.
Just came across this thread. I had a need of lightweight_call_once in my Boost.FSM library and implemented it. It is not implemented as an internal part of the library, but rather as a common tool, like lightweight_mutex. It can be found here: http://tinyurl.com/yjozfn I hope it will make it to Boost after the library review. -- Best regards, Andrey mailto:andysem@mail.ru