
12 May
2008
12 May
'08
12:01 p.m.
Anthony Williams:
One way to do this is have the pool use packaged_tasks internally, and set a wait callback which is invoked when a thread waits on a future from a pool task. When the callback is invoked by the waiting thread (as part of the call to wait()), if that waiting thread is a pool thread, it can proceed as above.
It actually doesn't matter whether the waiting thread is a pool thread or not. If the task hasn't been scheduled, it can be "stolen" and executed synchronously from within the wait().