|
Boost : |
From: Andrey Semashev (andysem_at_[hidden])
Date: 2007-08-22 14:08:54
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:
I hope it will make it to Boost after the library review.
-- Best regards, Andrey mailto:andysem_at_[hidden]
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk