Filip Konvicka:
2. The basic technique is
http://www.decadentplace.org.uk/pipermail/cpp-threads/2006-August/001082.htm... (except that the store_release to count_ is not necessary, it's under a lock, count_ = 1 is sufficient)
but, as I point out, it requires an atomic thread ID type.
One could probably use boost::detail::spinlock_pool for that.
It would probably be too slow. On platforms where the native "thread ID" is not an atomic type, one might use (in "C++0x pseudocode") unsigned get_thread_id() { static thread_local unsigned t_tid; static std::atomic<unsigned> s_tid; if( t_tid == 0 ) { t_tid = ++s_tid; } return t_tid; }
Peter, thanks for providing this :-) BTW, do you plan to release spinlocks as a regular Boost library?
I'm not ready to do that at the moment.