Boost logo

Boost :

From: Robin Boerdijk (robin_boerdijk_at_[hidden])
Date: 2006-01-18 02:49:53


> Robin Boerdijk wrote:
> >
> > "if the sender causes [signals] the event before the receiver waits
> for
> > it, the receiver will remain delayed until the next event is caused
> > [signalled]".
> >
>
> But I struck this exact problem the other day with boost threads
> condition variables. Both notify_one() & notify_all() have no effect
> if
> there are no threads waiting:
>
> http://boost.org/doc/html/condition.html

This is getting a bit off-topic, but to get a Windows style auto-reset
events you need a mutex, a condition variable and a boolean flag. It
would look something like this:

signal event:
    lock mutex
    set boolean flag
    notify condition variable
    unlock mutex

wait for event:
    lock mutex
    while not boolean flag set
        wait for condition variable
    reset boolean flag
    unlock mutex

This is a Windows style auto-reset event. My original question was (and
still is), what is wrong with this?

Robin Boerdijk

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com


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