diff options
Diffstat (limited to 'boost/thread/executors/basic_thread_pool.hpp')
-rw-r--r-- | boost/thread/executors/basic_thread_pool.hpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/boost/thread/executors/basic_thread_pool.hpp b/boost/thread/executors/basic_thread_pool.hpp index 11283ddf42..64ba1e90e0 100644 --- a/boost/thread/executors/basic_thread_pool.hpp +++ b/boost/thread/executors/basic_thread_pool.hpp @@ -14,7 +14,7 @@ #include <boost/thread/detail/delete.hpp> #include <boost/thread/detail/move.hpp> #include <boost/thread/scoped_thread.hpp> -#include <boost/thread/sync_queue.hpp> +#include <boost/thread/concurrent_queues/sync_queue.hpp> #include <boost/thread/executors/work.hpp> #include <boost/thread/csbl/vector.hpp> @@ -36,7 +36,7 @@ namespace executors typedef csbl::vector<thread_t> thread_vector; /// the thread safe work queue - sync_queue<work > work_queue; + concurrent::sync_queue<work > work_queue; /// A move aware vector thread_vector threads; @@ -48,22 +48,19 @@ namespace executors */ bool try_executing_one() { - work task; try { - if (work_queue.try_pull_front(task) == queue_op_status::success) + work task; + if (work_queue.try_pull(task) == queue_op_status::success) { task(); return true; } return false; } - catch (std::exception& ) - { - return false; - } catch (...) { + std::terminate(); return false; } } @@ -90,17 +87,14 @@ namespace executors for(;;) { work task; - queue_op_status st = work_queue.wait_pull_front(task); + queue_op_status st = work_queue.wait_pull(task); if (st == queue_op_status::closed) return; task(); } } - catch (std::exception& ) - { - return; - } catch (...) { + std::terminate(); return; } } @@ -134,7 +128,7 @@ namespace executors * * \b Throws: Whatever exception is thrown while initializing the needed resources. */ - basic_thread_pool(unsigned const thread_count = thread::hardware_concurrency()) + basic_thread_pool(unsigned const thread_count = thread::hardware_concurrency()+1) { try { @@ -275,18 +269,18 @@ namespace executors template <typename Closure> void submit(Closure & closure) { - work_queue.push_back(work(closure)); + work_queue.push(work(closure)); } #endif void submit(void (*closure)()) { - work_queue.push_back(work(closure)); + work_queue.push(work(closure)); } template <typename Closure> void submit(BOOST_THREAD_RV_REF(Closure) closure) { - work_queue.push_back(work(boost::forward<Closure>(closure))); + work_queue.push(work(boost::forward<Closure>(closure))); } /** |