|
Boost Users : |
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2007-01-22 18:14:35
On 1/22/07, Sohail Somani <s.somani_at_[hidden]> wrote:
>
>
> Hi,
>
> Perhaps the path-of-least-debugging is to use boost::once?
It definitely is. But if you could find a way to make it better, even with
complicated and platform-dependent code, and then wrap it up into something
usable, have it tested and peer-reviewed, and placed somewhere we could all
use it, it would still be useful.
Note that in the sentences above, I intentionally avoided mentioning
anything about the particular problem, as it is a general truth - library
code is allowed (at least somewhat) to be more complicated, if you assume it
is going to be more used and more reviewed and more tested.
Sohail
P.S. In this particular case, I don't think you can get better than:
- a read barrier and if-branch in the already-initted case
- that + a write barrier in the init case
- all wrapped into a single int.
which is slightly, but not much better than a mutex. It is also slightly
better than most implementations of boost::once/pthread_once, and much
better than some, depending on platform.
Tony
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net