Boost logo

Boost Users :

From: James E Taylor (james_at_[hidden])
Date: 2005-08-18 08:07:07

Thanks, that makes sense.

Ben Hutchings <ben.hutchings_at_[hidden]> wrote :

> James E Taylor wrote:
> &gt;I hope this isn't a stupid question, but....
> &gt;
> &gt;Is the boost mutex constructor thread-safe?
> &gt;
> &gt;
> Clearly it's unsafe for multiple threads to call a constructor on the
> same block of memory concurrently. To answer the real question, dynamic
> initialisation of local static variables is generally not thread-safe.
> &gt;and my worry is that both threads could attempt to do the static
> initialisation of m concurrently. Is there protection against this? Is it
> even possible to protect against this?
> &gt;
> &gt;I've tried to use boost::call_once, which would give sufficient guarantees
> but it's quite inflexible as nothing can be passed to or from the function
> being called.
> &gt;
> &gt;
> I don't see that there's any other way to do this using current C++ and
> Boost.
> Ben.
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]

James E Taylor

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at