Subj : Re: std::msync To : comp.programming.threads From : Peter Dimov Date : Sat Apr 02 2005 02:23 pm Alexander Terekhov wrote: > class sp_counted_base { > /* ... */ > typedef refcount count; > count use_count_, self_count_; > /* ... */ > public: > /* ... */ > sp_counted_base() : use_count_(1), self_count_(1) { } > > void add_ref() throw() { > use_count_.increment(); // naked > } > > bool lock() throw() { > return use_count_.increment_if_not_min(); // naked > } > > void weak_add_ref() throw() { > self_count_.increment(); // naked > } > > void weak_release() throw() { > if (!self_count_.decrement(msync::acq, count::may_not_store_min)) > destruct(); > } > > void release() throw() { > if (!use_count_.decrement()) { // "full" release-acquire protocol > dispose(); > if (!self_count_.decrement(msync::rel, count::may_not_store_min)) > destruct(); > } > } Question: your labeled approach only maps well to IA64 (and to a lesser extent x86), right? On platforms with bidirectional fences, could it be possible for the labeled approach to produce suboptimal code? IOW can the algorithm above be improved if it's known that the target platform has bidirectional fences and does not support labels? .