|
Boost : |
From: Frank Mori Hess (fmhess_at_[hidden])
Date: 2008-02-08 08:29:26
On Friday 08 February 2008 02:59, Colin Caughie wrote:
> Those URLs don't work for me, but presumably what you want is something
> that blocks until something is queued to be run by one of the threads in
> the group. My suggestion would be to use semaphores rather than mutexes
> for this. You initialize the semaphore count to 0 so that the first time
> you wait for it you immediately block. When another thread signals the
> semaphore you wake up.
>
> You'll have to write your own cross-platform semaphore class though as
> Boost.Thread doesn't have one.
Why would you do that? Boost.thread does provide boost::condition, which
isn't exactly a semaphore but conditions are designed for just the purpose
you describe.
-- Frank
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk