Boost logo

Boost Users :

Subject: Re: [Boost-users] condition variable predicate and lambda
From: Nat Linden (nat_at_[hidden])
Date: 2011-10-18 16:07:26


On Tue, Oct 18, 2011 at 3:24 PM, Christopher Pisz <cpisz_at_[hidden]> wrote:

> I want to do something simple, but implementing it seems awfully complex.

You've left a lot of the requirements unstated, but you seem to be
talking about cross-thread communication, and that domain is fraught
with peril. It's inherently complex.

> All I want to do is wait for a specified amount of time for a member variable
> of my class to equal a certain value.

So, is some other thread going to set it to that value? If not, we
could wait a long time...

Apparently you'd need to protect both the 'set' access and the testing access.

You also seem to be stating two different behaviors in the sentence above:

- Do not return until the variable has been set as desired.
- Do not wait longer than a specified timeout. (Then what? Exception?
Return a flag value?)

I haven't messed with cross-thread communication myself, so any
example code I propose is quite likely to be horribly wrong. I'm
merely suggesting that your initial mail may not be clear enough for
people who understand this domain to give you a solid answer.


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