size_policies.hpp
Go to the documentation of this file.
00001 
00018 #ifndef THREADPOOL_SIZE_POLICIES_HPP_INCLUDED
00019 #define THREADPOOL_SIZE_POLICIES_HPP_INCLUDED
00020 
00021 
00022 
00024 namespace boost { namespace threadpool
00025 {
00026 
00031   template<typename Pool>
00032   struct empty_controller
00033   {
00034     empty_controller(typename Pool::size_policy_type&, shared_ptr<Pool>) {}
00035   };
00036 
00037 
00042   template< typename Pool >
00043   class resize_controller
00044   {
00045     typedef typename Pool::size_policy_type size_policy_type;
00046     reference_wrapper<size_policy_type> m_policy;
00047     shared_ptr<Pool> m_pool;                           
00048 
00049   public:
00050     resize_controller(size_policy_type& policy, shared_ptr<Pool> pool)
00051       : m_policy(policy)
00052       , m_pool(pool)
00053     {
00054     }
00055 
00056     bool resize(size_t worker_count)
00057     {
00058       return m_policy.get().resize(worker_count);
00059     }
00060   };
00061 
00062 
00067   template<typename Pool>
00068   class static_size
00069   {
00070     reference_wrapper<Pool volatile> m_pool;
00071 
00072   public:
00073     static void init(Pool& pool, size_t const worker_count)
00074     {
00075       pool.resize(worker_count);
00076     }
00077 
00078     static_size(Pool volatile & pool)
00079       : m_pool(pool)
00080     {}
00081 
00082     bool resize(size_t const worker_count)
00083     {
00084       return m_pool.get().resize(worker_count);
00085     }
00086 
00087     void worker_died_unexpectedly(size_t const new_worker_count)
00088     {
00089       m_pool.get().resize(new_worker_count + 1);
00090     }
00091 
00092     // TODO this functions are not called yet
00093     void task_scheduled() {}
00094     void task_finished() {}
00095   };
00096 
00097 } } // namespace boost::threadpool
00098 
00099 #endif // THREADPOOL_SIZE_POLICIES_HPP_INCLUDED


or_libs
Author(s): Viktor Seib
autogenerated on Tue Jan 7 2014 11:24:03