21 Nov
2007
21 Nov
'07
10:39 p.m.
On Wed, 21 Nov 2007 23:25:36 +0100, Fabian Sturm wrote:
This works fine and A will wait until the result is available and it doens't matter if it starts waiting before or after B finished calculaating. But the problem now is that B also needs to wait for A to reach the point in execution.
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. -- Sohail Somani http://uint32t.blogspot.com