Boost logo

Boost :

From: Johan Torp (johan.torp_at_[hidden])
Date: 2008-06-02 13:32:52

There has been some discussions about exposing a wait-callback in futures, a
hook which is executed whenever someone calls wait. One of the motivations
has been to efficiently re-use threads within a thread pool when a task is
waiting on a future. The idea is to execute another task in the
future::wait() call to avoid thread context switching and to need less
worker threads. I've presented some arguments why this might cause
unexpected problems. Here is a very crude draft of an alternative
thread-pool interface which would allow thread re-use but in an explicit

Let launch_in_pool come in two flavours, one without surprising thread
re-use and one with explicit support for it. I hope the interfaces are

template<class R>
future<R> launch_in_pool(function<R()> task);

template<class R>
future<R> launch_in_pool(function<R(thread_pool& pool)> task);

/// The thread_pool class is only to be used by code executed by worker
class thread_pool
  template<class R, class F>
  future<R> submit_child_task(const F& child_task);

 /// Waits until all child tasks are ready
  void yielding_wait(yield_type yt);



View this message in context:
Sent from the Boost - Dev mailing list archive at

Boost list run by bdawes at, gregod at, cpdaniel at, john at