irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

thread_pool.hpp
Go to the documentation of this file.
1 #ifndef IRODS_THREAD_POOL_HPP
2 #define IRODS_THREAD_POOL_HPP
3 
4 #include <utility>
5 
6 #include <boost/asio.hpp>
7 
8 namespace irods
9 {
11  {
12  public:
13  explicit thread_pool(int _size)
14  : pool_{static_cast<std::size_t>(_size)}
15  {
16  }
17 
18  void join()
19  {
20  pool_.join();
21  }
22 
23  void stop()
24  {
25  pool_.stop();
26  }
27 
28  template <typename Function>
29  static void dispatch(thread_pool& _pool, Function&& _func)
30  {
31  boost::asio::dispatch(_pool.pool_, std::forward<Function>(_func));
32  }
33 
34  template <typename Function>
35  static void post(thread_pool& _pool, Function&& _func)
36  {
37  boost::asio::post(_pool.pool_, std::forward<Function>(_func));
38  }
39 
40  template <typename Function>
41  static void defer(thread_pool& _pool, Function&& _func)
42  {
43  boost::asio::defer(_pool.pool_, std::forward<Function>(_func));
44  }
45 
46  private:
47  boost::asio::thread_pool pool_;
48  };
49 } // namespace irods
50 
51 #endif // IRODS_THREAD_POOL_HPP
52 
irods::thread_pool::post
static void post(thread_pool &_pool, Function &&_func)
Definition: thread_pool.hpp:35
irods::thread_pool::thread_pool
thread_pool(int _size)
Definition: thread_pool.hpp:13
irods::thread_pool::dispatch
static void dispatch(thread_pool &_pool, Function &&_func)
Definition: thread_pool.hpp:29
irods
Definition: apiHandler.hpp:35
irods::thread_pool::stop
void stop()
Definition: thread_pool.hpp:23
irods::thread_pool::join
void join()
Definition: thread_pool.hpp:18
irods::thread_pool::defer
static void defer(thread_pool &_pool, Function &&_func)
Definition: thread_pool.hpp:41
irods::thread_pool
Definition: thread_pool.hpp:11
irods::thread_pool::pool_
boost::asio::thread_pool pool_
Definition: thread_pool.hpp:47