Boost logo

Boost Users :

From: Fabian Sturm (f_at_[hidden])
Date: 2007-11-21 19:56:59


Hi!

Am Mittwoch, den 21.11.2007, 22:39 +0000 schrieb Sohail Somani:
> Why not do this:
>
> void threadB()
> {
> g_value = do_my_expensive_calc();
> barrier2.wait(); // start waiting *after* calculation is done
> }
>
> void threadA()
> {
> barrier2.wait();
> // now can read value
> do_something_with_value(g_value)
> }
>
> Then thread B can calculate without waiting for thread A but neither
> thread will exit until they both reach the barrier.

A well I guess I wasn't expressing good enough. I look for a nice
solution where thread B is completely independent of A. But A waits for
B doing some work.

e.g.

void threadB ()
{
  do_something ();

  g_value = do_my_expensive_calc ();

  inform_thread_A ();

  do_something_else ();
}

So a barrier won't work, since it synchronizes both threads.

Thanks, Fabian


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