|
Boost Users : |
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2008-07-25 12:11:00
"Peter Dimov" <pdimov_at_[hidden]> writes:
> Anthony Williams:
>
>> However, it is never safe to destroy any object whilst another thread
>> might still be in a member function.
>
> I believe that this is a "POSIX destruction safety" issue. POSIX CVs
> are supposed to support such code.
POSIX CVs are supposed to support broadcast immediately before
destroy. What we have here is the waiting thread doing the
destruction, which is not guaranteed safe by POSIX, as far as I know.
>> If you use your mutex to protect the notify too, everything will be fine.
>
> I think that if the mutex doesn't offer "POSIX destruction safety",
> the code can still fail. Thread A may be unblocked and destroy the
> mutex while thread B is still in mutex::unlock.
Hmm. You're probably right. If the notify was protected by the mutex
this would require that the notifying thread was still in the unlock
even when the waiting thread had woken, acquired the lock and released
the lock. Though this is unlikely, it could happen. Ouch.
Anthony
-- Anthony Williams | Just Software Solutions Ltd Custom Software Development | http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL
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