Subject: Re: [boost] [thread] semaphore
From: Michael Marcin (mike.marcin_at_[hidden])
Date: 2013-10-02 12:44:54
On 9/18/2013 12:04 PM, Gottlob Frege wrote:
> On Wed, Sep 18, 2013 at 12:33 PM, Jonathan Wakely
>> On 18 September 2013 17:28, Gottlob Frege wrote:
>>> But it still doesn't make it easy to use. It might have been easier to
>>> somehow wrap the lock and CV together (and a lambda for the condition?)
>>> tell people to make sure they also lock the same CV+lock thing when
>>> pushing/pulling from the queue.
>> I think the problem with wrapping them together is that the binding of
>> the three things is dynamic, not static. It's OK to use the same CV
>> with different mutexes (as long as no waits using different mutexes
>> ever overlap) although doing so correctly can be tricky :)
> I wouldn't let that stop a wrapping - most cases don't need that, and you
> could still use "raw" CVs and locks for that.
> I think it is more likely that the "devil is in the details". If we
> actually sat down and tried to make a simple+powerful class, we would find
> the gotchas. (Tends to happen with simple+powerful.)
> But it might be worth trying.
FWIW latch is one such all-in-one class albeit without a customizable
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk