Boost logo

Boost Users :

Subject: Re: [Boost-users] threads and async questions and asnwers
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2015-06-03 13:37:39


On Wed, Jun 3, 2015 at 10:37 AM, Victor Yankee
<victor.whiskey.yankee_at_[hidden]> wrote:
> The root of the problem is that I wanted 2 worker threads to communicate
> asynchronously via "one-way" signals and expected this:
>
> Time Action
> -------- -----------------------------------
> 1 Thread 1: raises signal
>
> 2 Thread 1: set up and wait for reply signal with a timeout
> Thread 2: catches signal
>
> 3 Thread 2: composes and raises reply signal
>
> 4 Thread 1: catches reply
>
> But what happens is that Thread 2 replies before Thread 1 can set up the
> wait for the reply, so it times out, even though the reply was actually
> sent.
>
>
>
> What is the best way to fix this problem?
>

Are you using Boost.Signals2 (signals and slots) ? Or condition
variables (condvars) ?

Where is the answer written? It is a global integer (ie static int
answer = 42;) or somehow sent with the signal?

Do you understand "spurious wakeups" (if using condvars) ?

Tony


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