Boost logo

Boost :

Subject: Re: [boost] [1.44] Beta progress?
From: Gaetano Mendola (mendola_at_[hidden])
Date: 2010-07-26 09:55:42


On 07/26/2010 11:25 AM, Anthony Williams wrote:
> I have thought about this problem lots, and decided that you cannot
> safely interrupt a condition variable wait on POSIX unless you have a
> mutex tied directly to each condition variable (as with
> condition_variable_any). I'm therefore not sure how to approach this ---
> either every boost::condition_variable has an extra pthread_mutex_t
> inside it, or interruption is limited to waits on
> boost::condition_variable_any.

I have to look in detail the boost::thread implementation to help you
here.
Is pthread_cancel() still a no go to be used in threads::interrupt
implementation?

Another source of hang with notify_all (and then with interrupt), is
the following usage pattern:

1. Thread A: acquires a lock on mutex Ma
2. Thread A: does a wait on the condition C: C.wait(Ma)
3. Thread B: acquires a lock on mutex Mb
4. Thread B: does a wait on the condition C: C.wait(Mb)

at this point a C.notify_all() doesn't awakes both threads, in order
to awake both threads two C.notify_one() calls are needed.

Regards
Gaetano Mendola


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