|
Boost Users : |
From: Kevin Heifner (heifner_k_at_[hidden])
Date: 2006-02-20 15:33:41
Tom Widmer wrote:
> That particular re-ordering is illegal. Remember, when a mutex is
> locked, no memory access or code that happens after the mutex is locked
> (in this case the assignment to lk) can be moved to before the mutex was
> locked (in other words, a mutex emits an appropriate memory barrier), so
> lk will not be assigned until after global_mutex is locked.
[...]
> This is different from DCL, where one of the paths does *not* lock the
> mutex - in the OP's code, all paths lock the mutex before accessing
> shared data, so there's no problem.
Right. The mutex is acquired in the constructor and therefore
provides the memory barrier needed. It looks wrong to my eyes
since I would never use raw new/delete in this context. Sorry
for the noise.
KevinH
-- Kevin Heifner heifner @ ociweb.com http://heifner.blogspot.com Object Computing, Inc. (OCI) www.ociweb.com
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