|
Boost Users : |
From: Sohail Somani (s.somani_at_[hidden])
Date: 2007-01-22 20:12:01
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.
--------------
Sure
--------------
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.
--------------
What I've found that pthread_once implementations end up using DBCL
anyway but the benefit of using it there is obviously that you don't
have to debug it since they put in the necessary barriers. As far as I'm
concerned the problem is solved. For the 0.0001% of C++ programmers that
actually need the performance and are willing to shell out the debugging
hours, they are more than welcome. I (personally) think a boost
singleton based on boost once would be good enough for everyone else
until there are solutions per os/hw combination. Do you think people
would like one?
Not to take away from your valid points of course.
Sohail
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