Boost logo

Boost Users :

Subject: [Boost-users] [interprocess] Is there a bug in spinlock atomic implementations 1.39 and 1.40?
From: Sakharuk, Vladimir (vladimir.sakharuk_at_[hidden])
Date: 2009-10-13 14:37:41


Hi all
> In both:
>
> boost/detail/spinlock_sync.hpp
> boost/detail/smart_ptr/spinlock_sync.hpp
>
>
> Spinlock does not has constructor, so it is possible to have
> spinlock::v_ uninitialized and not to equal zero.
> That means it may be locked by default and call below will always
> return false...
> bool try_lock()
> {
> int r = __sync_lock_test_and_set( &v_, 1 );
> return r == 0;
> }
> Am I missing something?
>
> Adding
> Spinlock(): v_(0) {}
> Looks like solves my issue.
> g++ 4.1.2 on suse 2.6.16.46
>
> Regards Vlad.
>

===============================================================================
 Please access the attached hyperlink for an important electronic communications disclaimer:
 http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html
 ===============================================================================
 



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