Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2007-11-14 11:01:12


On Nov 14, 2007, at 10:23 AM, Phil Endecott wrote:

> I note that N2447 and your code have some swap functions for locks.
> Are these atomic? Also operator=. (I don't think they are.)

No. locks are not intended to be referenced by more than one thread.
Only the mutex lock, try_lock, timed_lock and unlock functions are
intended to be referenced simultaneously by multiple threads. The
swap on locks does absolutely nothing to the referenced mutexes. It
simply swaps mutex references and ownership status among the locks.
Move assignment is similar except that it will call unlock() on any
currently referenced mutex if need be prior to the ownership transfer
from the source.

-Howard


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk