libjmmcg  build_2783
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq > Class Template Reference

This class of threads is used within the various thread_pool classes. More...

#include <pool_thread.hpp>

Inheritance diagram for jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq >:
[legend]
Collaboration diagram for jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq >:
[legend]

Public Types

using base_t = ppd::private_::thread_base< OST::thread_traits::api_params_type::api_type, typename OST::thread_traits::model_type >
 
using os_traits = OST
 
using model_type = typename OST::thread_traits::model_type
 
using exit_requested_type = ExitReq
 The exit event type. More...
 
- Public Types inherited from jmmcg::ppd::private_::thread_base< OST::thread_traits::api_params_type::api_type, OST::thread_traits::model_type >
typedef thread_os_traits< API, OST::thread_traits::model_type > os_traits
 
typedef os_traits::thread_traits thread_traits
 
typedef os_traits::lock_traits lock_traits
 
typedef os_traits::exception_type exception_type
 

Public Member Functions

 ~pool_thread () noexcept(false) FORCE_INLINE
 
const tstring __fastcall to_string () const noexcept(false) override final
 
- Public Member Functions inherited from jmmcg::ppd::private_::thread_base< OST::thread_traits::api_params_type::api_type, OST::thread_traits::model_type >
virtual void __fastcall create_running () noexcept(false) FORCE_INLINE
 Start the underlying kernel thread. More...
 
const thread_traits::api_params_type &__fastcall params () const noexcept(true) FORCE_INLINE
 
const thread_traits::api_params_type::suspend_count __fastcall suspend () noexcept(true) FORCE_INLINE
 
const thread_base< generic_traits::MS_Win32, heavyweight_threading >::thread_traits::api_params_type::suspend_count __fastcall suspend () noexcept(true)
 
const thread_traits::api_params_type::suspend_count __fastcall resume () noexcept(true) FORCE_INLINE
 
const thread_traits::api_params_type::states __fastcall state () const noexcept(true) FORCE_INLINE
 
bool __fastcall is_running () const noexcept(true) FORCE_INLINE
 
thread_traits::api_params_type::priority_type __fastcall kernel_priority () const noexcept(false) FORCE_INLINE
 
void __fastcall kernel_priority (const typename thread_traits::api_params_type::priority_type priority) noexcept(false) FORCE_INLINE
 
thread_traits::api_params_type::processor_mask_type __fastcall kernel_affinity () const noexcept(false) FORCE_INLINE
 
void __fastcall kernel_affinity (const typename thread_traits::api_params_type::processor_mask_type &mask) noexcept(false) FORCE_INLINE
 

Static Public Attributes

static constexpr generic_traits::api_type api_type =OST::thread_traits::api_params_type::api_type
 
- Static Public Attributes inherited from jmmcg::ppd::private_::thread_base< OST::thread_traits::api_params_type::api_type, OST::thread_traits::model_type >
static constexpr ppd::generic_traits::memory_access_modes memory_access_mode
 

Protected Member Functions

__stdcall pool_thread (exit_requested_type &exit_r, const typename os_traits::thread_traits::api_params_type::suspend_period_ms exit_wait_p=50) noexcept(false) FORCE_INLINE
 
- Protected Member Functions inherited from jmmcg::ppd::private_::thread_base< OST::thread_traits::api_params_type::api_type, OST::thread_traits::model_type >
__stdcall thread_base (const typename thread_traits::api_params_type::suspend_period_ms exit_wait_p) noexcept(false) FORCE_INLINE
 Create the wrapper object. Note that the underlying kernel thread will not have been started. More...
 
__stdcall thread_base (const thread_base &tb) noexcept(true) FORCE_INLINE
 
virtual __stdcall ~thread_base () noexcept(false) FORCE_INLINE
 Thread base dtor. More...
 
void __fastcall wait_thread_exit () noexcept(false) FORCE_INLINE
 
virtual thread_traits::api_params_type::states __fastcall process () noexcept(false)=0
 This is the main "work" function. Implement it to do some work in the thread. More...
 

Protected Attributes

exit_requested_typeexit_requested_
 This event is used by the pool to request that all thread members of the pool should exit. More...
 
- Protected Attributes inherited from jmmcg::ppd::private_::thread_base< OST::thread_traits::api_params_type::api_type, OST::thread_traits::model_type >
os_traits::thread_exception exception_thrown_in_thread
 This is to allow exceptions thrown in the contained thread to be (hopefully) propagated back to another thread on which that exception can be caught & handled. More...
 
lock_traits::critical_section_type thread_params_lock
 
thread_traits::api_params_type thread_params
 

Additional Inherited Members

- Public Attributes inherited from jmmcg::ppd::private_::thread_base< OST::thread_traits::api_params_type::api_type, OST::thread_traits::model_type >
const thread_traits::api_params_type::suspend_period_ms exit_wait_period
 

Detailed Description

template<typename OST, class ExitReq>
class jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq >

This class of threads is used within the various thread_pool classes.

Implementation details:

  1. It uses a shared exit event (which is owned by the thread pool class). This optimisation allows parallel exiting of the threads within the pool. Thus the destructor of the pool is faster.

Definition at line 104 of file pool_thread.hpp.

Member Typedef Documentation

◆ base_t

template<typename OST, class ExitReq>
using jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq >::base_t = ppd::private_::thread_base<OST::thread_traits::api_params_type::api_type, typename OST::thread_traits::model_type>

Definition at line 123 of file pool_thread.hpp.

◆ exit_requested_type

template<typename OST, class ExitReq>
using jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq >::exit_requested_type = ExitReq

The exit event type.

Definition at line 126 of file pool_thread.hpp.

◆ model_type

template<typename OST, class ExitReq>
using jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq >::model_type = typename OST::thread_traits::model_type

Definition at line 125 of file pool_thread.hpp.

◆ os_traits

template<typename OST, class ExitReq>
using jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq >::os_traits = OST

Definition at line 124 of file pool_thread.hpp.

Constructor & Destructor Documentation

◆ ~pool_thread()

template<typename OST, class ExitReq>
jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq >::~pool_thread ( )
inlinenoexcept

Definition at line 130 of file pool_thread.hpp.

◆ pool_thread()

template<typename OST, class ExitReq>
__stdcall jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq >::pool_thread ( exit_requested_type exit_r,
const typename os_traits::thread_traits::api_params_type::suspend_period_ms  exit_wait_p = 50 
)
inlineexplicitprotectednoexcept

Definition at line 143 of file pool_thread.hpp.

Member Function Documentation

◆ to_string()

template<typename OST, class ExitReq>
const tstring __fastcall jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq >::to_string ( ) const
inlinefinaloverridevirtualnoexcept

Member Data Documentation

◆ api_type

template<typename OST, class ExitReq>
constexpr generic_traits::api_type jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq >::api_type =OST::thread_traits::api_params_type::api_type
staticconstexpr

Definition at line 128 of file pool_thread.hpp.

◆ exit_requested_

template<typename OST, class ExitReq>
exit_requested_type& jmmcg::ppd::pool::private_::pool_thread< OST, ExitReq >::exit_requested_
protected

This event is used by the pool to request that all thread members of the pool should exit.

Definition at line 141 of file pool_thread.hpp.


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