The binding can't be done later. For principal reasons—a thread of execution has to be executing something.
What you need to do is create a function, that will take jobs, represented as boost::function
, from a queue and execute them. Than run this function in one or more threads.
I am not sure there is a thread-safe queue, but you can always use a regular std::deque
with boost::condition_variable
for waking up the threads and boost::mutex
for locking the deque.
You might want to look at Boost.Asio too. See also here.