size_policies.hpp
Go to the documentation of this file.
1 
18 #ifndef THREADPOOL_SIZE_POLICIES_HPP_INCLUDED
19 #define THREADPOOL_SIZE_POLICIES_HPP_INCLUDED
20 
21 
22 
24 namespace boost { namespace threadpool
25 {
26 
31  template<typename Pool>
33  {
34  empty_controller(typename Pool::size_policy_type&, shared_ptr<Pool>) {}
35  };
36 
37 
42  template< typename Pool >
44  {
45  typedef typename Pool::size_policy_type size_policy_type;
46  reference_wrapper<size_policy_type> m_policy;
48 
49  public:
50  resize_controller(size_policy_type& policy, shared_ptr<Pool> pool)
51  : m_policy(policy)
52  , m_pool(pool)
53  {
54  }
55 
56  bool resize(size_t worker_count)
57  {
58  return m_policy.get().resize(worker_count);
59  }
60  };
61 
62 
67  template<typename Pool>
69  {
70  reference_wrapper<Pool volatile> m_pool;
71 
72  public:
73  static void init(Pool& pool, size_t const worker_count)
74  {
75  pool.resize(worker_count);
76  }
77 
78  static_size(Pool volatile & pool)
79  : m_pool(pool)
80  {}
81 
82  bool resize(size_t const worker_count)
83  {
84  return m_pool.get().resize(worker_count);
85  }
86 
87  void worker_died_unexpectedly(size_t const new_worker_count)
88  {
89  m_pool.get().resize(new_worker_count + 1);
90  }
91 
92  // TODO this functions are not called yet
93  void task_scheduled() {}
94  void task_finished() {}
95  };
96 
97 } } // namespace boost::threadpool
98 
99 #endif // THREADPOOL_SIZE_POLICIES_HPP_INCLUDED
reference_wrapper< Pool volatile > m_pool
The namespace threadpool contains a thread pool and related utility classes.
empty_controller(typename Pool::size_policy_type &, shared_ptr< Pool >)
static_size(Pool volatile &pool)
bool resize(size_t const worker_count)
Pool::size_policy_type size_policy_type
bool resize(size_t worker_count)
SizePolicyController which allows resizing.
SizePolicy which preserves the thread count.
void worker_died_unexpectedly(size_t const new_worker_count)
SizePolicyController which provides no functionality.
shared_ptr< Pool > m_pool
to make sure that the pool is alive (the policy pointer is valid) as long as the controller exists ...
static void init(Pool &pool, size_t const worker_count)
resize_controller(size_policy_type &policy, shared_ptr< Pool > pool)
reference_wrapper< size_policy_type > m_policy


asr_descriptor_surface_based_recognition
Author(s): Allgeyer Tobias, Hutmacher Robin, Meißner Pascal
autogenerated on Mon Dec 16 2019 03:31:15