Professional Documents
Culture Documents
Boost Multi Threading
Boost Multi Threading
Here is a small C++ function which allows you to submit async jobs into the thread pool and
track their execution status using the concept of futures:
#include
#include
#include
#include
"boost/threadpool.hpp"
"boost/future.hpp"
"boost/utility/result_of.hpp"
"boost/shared_ptr.hpp"
return res;
boost::futures are now finally officially shipped with boost starting with 1.41 release.
boost::threadpool is not yet an official boost library, however you can find it here.
Much kudos to authors of these amazing libraries!
This entry was posted on Thursday, December 10th, 2009 at 12:18 am and is filed under async, multicore, boost,
c++. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback
from your own site.
Conception of Futures very popular on Java Platform also. But there is one thing that
Im missing in Futures - asynchronous completition. Sometimes there is no need to
wait for task to complete. All I need is to give task and completition function to thread
pool. For example:
Callable task = new LoadUserTask(userId);
executor.submit(task, new CompletionHandler {
public void onComplete(User user) {
user.setLastLoginTime(now());
}
});