|
Boost Users : |
Subject: Re: [Boost-users] boost::mutex synchronization problem
From: Anthony Williams (anthony.ajw_at_[hidden])
Date: 2009-05-05 06:42:40
Zachary Turner <divisortheory_at_[hidden]> writes:
> I've been trying to figure out if there's a simple way using condition
> variables and mutexes to design a function with the following properties
> (cliffs notes first, and then longer version in case it's not enough info):
>
> 1) there is a section of code in the function such that two threads cannot
> enter that section at the same time.
> 2) after leaving the section of code, the thread should wait for something to
> happen (signalled by another thread)
> 3) the waits in step 2 should be awoken in the order they occured.
There's nothing in boost to do this. I remember a thread on
comp.programming.threads about a FIFO mutex (which is what you seem to
want). Someone provided an implementation (which may well do what you
want), but the consensus seemed to be "don't do that". If your program
behaviour depends on threads being woken in a specific order then it may
be better to rewrite the code so it doesn't.
Anthony
-- Author of C++ Concurrency in Action | http://www.manning.com/williams just::thread C++0x thread library | http://www.stdthread.co.uk Just Software Solutions Ltd | http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976
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