Peter Dimov wrote: > > Alexander Terekhov wrote: > [...] > > bool acquire_strong_from_weak() { > > int status = pthread_refcount_enroll_one(&strong_count); // > [...] > > Or am I just missing and/or misunderstanding something? > > You are missing the fact that nobody (even Google) has a clue as to what > pthread_refcount_enroll_one is/does. ;-)
Ah. Sorry. Basically it's a rather simple "CAS"- ["compare-and-swap"] or "LL/SC"- [load-locked/store-conditional] based operation; in terms of proposed Java-atomics(*): <behaviorally, error checking aside> extern "C" int pthread_refcount_enroll_one(pthread_refcount_t* rc) { size_t value; do { if ( 0 == (value = rc->__get()) ) return PTHREAD_REFCOUNT_DROPPED_TO_ZERO; } while (!rc->__attemptUpdate(value, value + 1)); return 0; } regards, alexander. (*) [but WITHOUT any memory synchronization/barriers for _enroll_*()] http://groups.google.com/groups?threadm=3D8B257C.4D8D58F%40web.de (Subject: Re: rwlock using pthread_cond (or Win32 events) [last link retired; stuff is available here: <http://tinyurl.com/5mmj>]) _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost