libjmmcg  build_2783
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::ppd::thread_pool< pool_traits::work_distribution_mode_t::worker_threads_get_work< pool_traits::work_distribution_mode_t::queue_model_t::thread_owns_queue< pool_traits::work_distribution_mode_t::queue_model_t::stealing_mode_t::random > >, pool_traits::size_mode_t::fixed_size, PTT > Class Template Reference

This pool has a specified size, and the worker pool_threads steal each have a signalled_work_queue. More...

#include <thread_pool_workers.hpp>

Inheritance diagram for jmmcg::ppd::thread_pool< pool_traits::work_distribution_mode_t::worker_threads_get_work< pool_traits::work_distribution_mode_t::queue_model_t::thread_owns_queue< pool_traits::work_distribution_mode_t::queue_model_t::stealing_mode_t::random > >, pool_traits::size_mode_t::fixed_size, PTT >:
[legend]
Collaboration diagram for jmmcg::ppd::thread_pool< pool_traits::work_distribution_mode_t::worker_threads_get_work< pool_traits::work_distribution_mode_t::queue_model_t::thread_owns_queue< pool_traits::work_distribution_mode_t::queue_model_t::stealing_mode_t::random > >, pool_traits::size_mode_t::fixed_size, PTT >:
[legend]

Public Types

enum  erase_states { erase_states::failed_to_erase, erase_states::ignoring_result, erase_states::erased_successfully }
 
using base_t = private_::thread_pool_queue_model< pool_traits::work_distribution_mode_t::worker_threads_get_work< pool_traits::work_distribution_mode_t::queue_model_t::thread_owns_queue< pool_traits::work_distribution_mode_t::queue_model_t::stealing_mode_t::random > >, pool_traits::size_mode_t::fixed_size, PTT, private_::fixed_pool_of_threads< PTT, pool::private_::thread_types::steal< PTT::result_traits_, typename PTT::os_traits, PTT, pool_traits::work_distribution_mode_t::worker_threads_get_work< pool_traits::work_distribution_mode_t::queue_model_t::thread_owns_queue< pool_traits::work_distribution_mode_t::queue_model_t::stealing_mode_t::random > >::queue_model > > >
 
using pool_traits_type = typename base_t::pool_traits_type
 
using os_traits = typename base_t::os_traits
 
using thread_traits = typename base_t::thread_traits
 
using api_params_type = typename base_t::api_params_type
 
using pool_type = typename base_t::pool_type
 
using statistics_type = typename base_t::statistics_type
 
using work_distribution_mode = typename base_t::work_distribution_mode
 
using signalled_work_queue_type = typename base_t::signalled_work_queue_type
 

Public Member Functions

 BOOST_MPL_ASSERT ((std::is_same< typename std::is_same< typename PTT::os_traits::thread_traits::model_type, sequential_mode >::type, std::false_type >))
 
__stdcall thread_pool (const typename base_t::pool_type::size_type num_threads) noexcept(false) FORCE_INLINE
 Create the thread pool. More...
 
 thread_pool (thread_pool const &)=delete
 
__stdcall ~thread_pool () noexcept(false) FORCE_INLINE
 
template<typename ExecT >
erase_states __fastcall erase (ExecT &ec) noexcept(false)=delete
 Erase the specified, queued work. More...
 
const statistics_type __fastcall statistics () const noexcept(true) override FORCE_INLINE
 Obtain access to any statistics data collected by the operation of the thread_pool. More...
 

Detailed Description

template<class PTT>
class jmmcg::ppd::thread_pool< pool_traits::work_distribution_mode_t::worker_threads_get_work< pool_traits::work_distribution_mode_t::queue_model_t::thread_owns_queue< pool_traits::work_distribution_mode_t::queue_model_t::stealing_mode_t::random > >, pool_traits::size_mode_t::fixed_size, PTT >

This pool has a specified size, and the worker pool_threads steal each have a signalled_work_queue.

To reduce calls to the global operator new, and enhance scalability, the parallel algorithms (for_each(), transform(), etc, except merge() and sort()) internally pre-allocate a contiguous buffer of memory for their internal operations. This buffer grows O(p.log(p)) for p processors, with a constant that is ~200 bytes, so for millions of processors, megabytes could be allocated per parallel algorithm. This buffer is guaranteed to be released after all mutations on the elements within the collection are complete, which is usually before any waiting execution_context, constructed by the call to the parallel algorithm, would be released, but is not guaranteed. For each parallel algorithm (except merge() and sort()) exactly 2 calls to the global operator new are made by the library. For merge() the internal buffer grows as O(p.log(p).log(n)) with O(log(n)) calls to the global operator new, and for sort(), O(p.log(p).log(n)^2)) and O(log(n)^2) respectively.

Definition at line 470 of file thread_pool_workers.hpp.

Member Typedef Documentation

◆ api_params_type

◆ base_t

◆ os_traits

◆ pool_traits_type

◆ pool_type

◆ signalled_work_queue_type

◆ statistics_type

◆ thread_traits

◆ work_distribution_mode

Member Enumeration Documentation

◆ erase_states

Constructor & Destructor Documentation

◆ thread_pool() [1/2]

Create the thread pool.

Parameters
num_threadsThe number of threads in the pool, which must be greater than zero.

Definition at line 521 of file thread_pool_workers.hpp.

◆ thread_pool() [2/2]

◆ ~thread_pool()

The destruction of the collection of threads is sequential, but the threads themselves can exit in parallel, thus speeding up the clean-up of the pool.

Definition at line 545 of file thread_pool_workers.hpp.

Member Function Documentation

◆ BOOST_MPL_ASSERT()

◆ erase()

◆ statistics()

Obtain access to any statistics data collected by the operation of the thread_pool.

Algorithmic complexity when specialised with no_statistics: constant time, otherwise O(pool_size()). Note that the value computed for the statistics_type::total_vertical_work() is guaranteed to be accurate. The value computed for the statistics_type::total_hrz_work() is guaranteed not be more than the value as if it were computed atomically. Therefore the following holds: statistics_type::total_work_added()>=statistics_type::total_vertical_work()+statistics_type::total_hrz_work()

Definition at line 567 of file thread_pool_workers.hpp.

References jmmcg::ppd::control_flow_graph< OST >::add_cfg_details< Node >::params::params().


The documentation for this class was generated from the following file: