| The Gaudi Framework v28r2-patches (bc4ad17a)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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>
32 struct empty_controller
33 {
34 empty_controller(typename Pool::size_policy_type&, shared_ptr<Pool>) {}
35 };
36
37
42 template< typename Pool >
43 class resize_controller
44 {
45 typedef typename Pool::size_policy_type size_policy_type;
46 reference_wrapper<size_policy_type> m_policy;
47 shared_ptr<Pool> m_pool;
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>
68 class static_size
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
boost::threadpool::static_size::task_scheduled
void task_scheduled()
Definition: size_policies.hpp:93
boost::threadpool::static_size::m_pool
reference_wrapper< Pool volatile > m_pool
Definition: size_policies.hpp:70
boost
The namespace threadpool contains a thread pool and related utility classes.
Definition: iter_pos.hpp:13
boost::threadpool::empty_controller::empty_controller
empty_controller(typename Pool::size_policy_type &, shared_ptr< Pool >)
Definition: size_policies.hpp:34
boost::threadpool::static_size::static_size
static_size(Pool volatile &pool)
Definition: size_policies.hpp:78
boost::threadpool::static_size::resize
bool resize(size_t const worker_count)
Definition: size_policies.hpp:82
boost::threadpool::resize_controller::size_policy_type
Pool::size_policy_type size_policy_type
Definition: size_policies.hpp:45
boost::threadpool::resize_controller::resize
bool resize(size_t worker_count)
Definition: size_policies.hpp:56
boost::threadpool::resize_controller
SizePolicyController which allows resizing.
Definition: size_policies.hpp:43
pool
Definition: PoolClasses.h:7
boost::threadpool::static_size
SizePolicy which preserves the thread count.
Definition: size_policies.hpp:68
boost::threadpool::static_size::worker_died_unexpectedly
void worker_died_unexpectedly(size_t const new_worker_count)
Definition: size_policies.hpp:87
boost::threadpool::empty_controller
SizePolicyController which provides no functionality.
Definition: size_policies.hpp:32
boost::threadpool::resize_controller::m_pool
shared_ptr< Pool > m_pool
to make sure that the pool is alive (the policy pointer is valid) as long as the controller exists ...
Definition: size_policies.hpp:47
boost::threadpool::static_size::init
static void init(Pool &pool, size_t const worker_count)
Definition: size_policies.hpp:73
boost::threadpool::static_size::task_finished
void task_finished()
Definition: size_policies.hpp:94
boost::threadpool::resize_controller::resize_controller
resize_controller(size_policy_type &policy, shared_ptr< Pool > pool)
Definition: size_policies.hpp:50
boost::threadpool::resize_controller::m_policy
reference_wrapper< size_policy_type > m_policy
Definition: size_policies.hpp:46