|
Boost : |
From: Tony Juricic (tonygeek_at_[hidden])
Date: 2004-09-05 17:55:47
"Jeff Garland" wrote:
> STLPort -- www.stlport.org implements them.
Well.. no, not really. At least not in the way Java library does it, which
is closest to what I had in mind.
According to the documentation only explicit locks are in allocators and
there is this telling comment:
"This decision is different from that made by the Java designers. There are
two reasons for that. First, for security reasons Java must guarantee that
even in the presence of unprotected concurrent accesses to a container, the
integrity of the virtual machine cannot be violated. Such safety constraints
were clearly not a driving force behind either C++ or STL. Secondly,
performance was a more important design goal for STL than it was for the
Java standard library."
The following excerpt from STLPort _threads.h file shows that there is still
work to be done:
// This should be portable, but performance is expected
// to be quite awful. This really needs platform specific
// code.
inline __stl_atomic_t _Atomic_swap(volatile __stl_atomic_t * __p,
__stl_atomic_t __q) {
_Swap_lock_struct<0>::_S_swap_lock._M_acquire_lock();
__stl_atomic_t __result = *__p;
*__p = __q;
_Swap_lock_struct<0>::_S_swap_lock._M_release_lock();
return __result;
}
All in all, IMO there is ample space for a small, even if quite ambitious
project of implementing at least few cross-platform, fully thread-safe
lock-free (to address performance concerns mentioned in the quote above)
containers.
Tony
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk