#include #include #include "thread_pool.hpp" using namespace std; struct work { boost::mutex &mutex; unsigned int val; work(boost::mutex &m, const unsigned int v) : mutex(m),val(v) {} void operator()() const { boost::mutex::scoped_lock lock(mutex); cout << val << '\r'; } }; int main(void) { try { thread_pool p(2); boost::mutex m; for(unsigned int i=0; i<1000; i++) p.queue(work(m, i)); } catch(exception &ex) { cerr << "exception occured: " << ex.what() << endl; return -1; } return 0; }