Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:01:11

0001 // Copyright (C) 2014 Ian Forbed
0002 // Copyright (C) 2014 Vicente J. Botet Escriba
0003 //
0004 //  Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 //  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 
0008 #ifndef BOOST_THREAD_EXECUTORS_SCHEDULED_THREAD_POOL_HPP
0009 #define BOOST_THREAD_EXECUTORS_SCHEDULED_THREAD_POOL_HPP
0010 
0011 #include <boost/thread/detail/config.hpp>
0012 #if defined BOOST_THREAD_PROVIDES_FUTURE_CONTINUATION && defined BOOST_THREAD_PROVIDES_EXECUTORS && defined BOOST_THREAD_USES_MOVE
0013 
0014 #include <boost/thread/executors/detail/scheduled_executor_base.hpp>
0015 
0016 namespace boost
0017 {
0018 namespace executors
0019 {
0020 
0021   class scheduled_thread_pool : public detail::scheduled_executor_base<>
0022   {
0023   private:
0024     thread_group _workers;
0025   public:
0026 
0027     scheduled_thread_pool(size_t num_threads) : super()
0028     {
0029       for(size_t i = 0; i < num_threads; i++)
0030       {
0031         _workers.create_thread(bind(&super::loop, this));
0032       }
0033     }
0034 
0035     ~scheduled_thread_pool()
0036     {
0037       this->close();
0038       _workers.interrupt_all();
0039       _workers.join_all();
0040     }
0041 
0042   private:
0043     typedef detail::scheduled_executor_base<> super;
0044   }; //end class
0045 
0046 } //end executors namespace
0047 
0048 using executors::scheduled_thread_pool;
0049 
0050 } //end boost
0051 #endif
0052 #endif
0053