libjmmcg  build_2783
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr > Class Template Reference

Class that implements the horizontal execution algorithm. More...

#include <thread_client_context.hpp>

Inheritance diagram for jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >:
[legend]
Collaboration diagram for jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >:
[legend]

Static Public Attributes

static constexpr ppd::generic_traits::memory_access_modes memory_access_mode
 
- Static Public Attributes inherited from jmmcg::ppd::private_::horizontal_execution_itf< RD, TPB, Del, AtCtr >
static constexpr generic_traits::return_data result_traits_ =RD
 
static constexpr ppd::generic_traits::memory_access_modes memory_access_mode
 

Protected Types

typedef horizontal_execution_itf< RD, TPB, Del, AtCtr > base_t
 
typedef base_t::thread_pool_type thread_pool_type
 
typedef base_t::pool_traits_type pool_traits_type
 
typedef base_t::pool_type pool_type
 
typedef base_t::os_traits os_traits
 
typedef base_t::thread_wk_t thread_wk_t
 

Protected Member Functions

 horizontal_execution (thread_pool_type &p, thread_wk_t &core_work) noexcept(true) FORCE_INLINE
 
 ~horizontal_execution () noexcept(false) FORCE_INLINE
 
void __fastcall wait_or_horizontal_thread () const noexcept(false) final override
 Wait upon the core_work to complete process(), or process() items from the pool::batch_details. More...
 
- Protected Member Functions inherited from jmmcg::ppd::private_::horizontal_execution_itf< RD, TPB, Del, AtCtr >
constexpr horizontal_execution_itf () noexcept(true) FORCE_INLINE
 
 ~horizontal_execution_itf () noexcept(true) FORCE_INLINE
 Can't be used polymorphically - to maintain the concept that this is a stack allocated object. More...
 
virtual work_complete_t &__fastcall work_complete () noexcept(true)=0
 
virtual work_complete_t &__fastcall work_complete () const noexcept(true)=0
 
virtual const thread_wk_t &__fastcall core_work () const noexcept(true)=0
 
bool __fastcall work_done () const noexcept(true) FORCE_INLINE
 Check to see if the work has been completed. More...
 

Protected Attributes

thread_pool_typepool
 

Additional Inherited Members

- Public Types inherited from jmmcg::ppd::private_::horizontal_execution_itf< RD, TPB, Del, AtCtr >
typedef TPB thread_pool_type
 
typedef thread_pool_type::pool_traits_type pool_traits_type
 The pool traits. More...
 
typedef thread_pool_type::os_traits os_traits
 
typedef thread_pool_type::pool_type pool_type
 
typedef os_traits::lock_traits::anon_event_type atomic_t
 
typedef os_traits::exception_type exception_type
 
typedef closure::thread_wk_async_t< RD, os_traits, Del, AtCtr, typename pool_traits_type::cfg_type > thread_wk_t
 
typedef thread_wk_t::work_complete_t work_complete_t
 This atomic object is the object that is used to signal to a waiting future that the work has been completed. More...
 
- Public Member Functions inherited from jmmcg::ppd::private_::horizontal_execution_itf< RD, TPB, Del, AtCtr >
 horizontal_execution_itf (horizontal_execution_itf const &)=delete
 

Detailed Description

template<generic_traits::return_data RD, class TPB, template< class > class Del, template< class > class AtCtr>
class jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >

Class that implements the horizontal execution algorithm.

It wait for work on the main thread_pool::signalled_work_queue at low priority (to try and ensure that the pool_threads are more likely to get the thread_wk_t), takes one item at a time, i.e. no batching, GSS(k), where k=1, and resultant work is placed back into the thread_pool::signalled_work_queue, to be available for all threads.

Due to the PThreads API, which lacks wait for multiple objects, one has to create another thread to execute the work horizontally whilst the execution context is held. Then once the execution context is released, one has to cancel the thread, but be hyper-careful about when one can cancel the thread to ensure that not only is any work it is processing completed, but also that any C++ objects it is holding have their dtors correctly run. Yuck. The thread is created in the call to get_results(), only if the work has not been completed.

See also
get_results()

Definition at line 662 of file thread_client_context.hpp.

Member Typedef Documentation

◆ base_t

template<generic_traits::return_data RD, class TPB, template< class > class Del, template< class > class AtCtr>
typedef horizontal_execution_itf<RD, TPB, Del, AtCtr> jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >::base_t
protected

Definition at line 664 of file thread_client_context.hpp.

◆ os_traits

template<generic_traits::return_data RD, class TPB, template< class > class Del, template< class > class AtCtr>
typedef base_t::os_traits jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >::os_traits
protected

Definition at line 668 of file thread_client_context.hpp.

◆ pool_traits_type

template<generic_traits::return_data RD, class TPB, template< class > class Del, template< class > class AtCtr>
typedef base_t::pool_traits_type jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >::pool_traits_type
protected

Definition at line 666 of file thread_client_context.hpp.

◆ pool_type

template<generic_traits::return_data RD, class TPB, template< class > class Del, template< class > class AtCtr>
typedef base_t::pool_type jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >::pool_type
protected

Definition at line 667 of file thread_client_context.hpp.

◆ thread_pool_type

template<generic_traits::return_data RD, class TPB, template< class > class Del, template< class > class AtCtr>
typedef base_t::thread_pool_type jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >::thread_pool_type
protected

Definition at line 665 of file thread_client_context.hpp.

◆ thread_wk_t

template<generic_traits::return_data RD, class TPB, template< class > class Del, template< class > class AtCtr>
typedef base_t::thread_wk_t jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >::thread_wk_t
protected

Definition at line 669 of file thread_client_context.hpp.

Constructor & Destructor Documentation

◆ horizontal_execution()

template<generic_traits::return_data RD, class TPB, template< class > class Del, template< class > class AtCtr>
jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >::horizontal_execution ( thread_pool_type p,
thread_wk_t core_work 
)
inlineprotectednoexcept

Definition at line 671 of file thread_client_context.hpp.

◆ ~horizontal_execution()

template<generic_traits::return_data RD, class TPB, template< class > class Del, template< class > class AtCtr>
jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >::~horizontal_execution ( )
inlineprotectednoexcept

Definition at line 674 of file thread_client_context.hpp.

Member Function Documentation

◆ wait_or_horizontal_thread()

template<generic_traits::return_data RD, class TPB, template< class > class Del, template< class > class AtCtr>
void __fastcall jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >::wait_or_horizontal_thread ( ) const
inlinefinaloverrideprotectedvirtualnoexcept

Wait upon the core_work to complete process(), or process() items from the pool::batch_details.

When items are directly process()ed from the pool::batch_details whilst waiting for the attaced core_work to complete, I term this as "horizontal threading", as opposed to "vertical threading", which is when core_work items are process()ed in pool_thread pool::thread_types::steal::process(), possibly being batched. This function will attempt to process core_work from the signalled_work_queue, or if the wk_queue_item() upon which it is waiting has been completed, will return. Batching is carefully done: if there are items in the pool::batch_details, then these will be processed first, but only from the same thread as this one.

See also
steal::batch_type, pool::batch_details

Reimplemented from jmmcg::ppd::private_::horizontal_execution_itf< RD, TPB, Del, AtCtr >.

Definition at line 683 of file thread_client_context.hpp.

Member Data Documentation

◆ memory_access_mode

template<generic_traits::return_data RD, class TPB, template< class > class Del, template< class > class AtCtr>
constexpr ppd::generic_traits::memory_access_modes jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >::memory_access_mode
staticconstexpr
Initial value:

To assist in allowing compile-time computation of the algorithmic order of the threading model.

Definition at line 839 of file thread_client_context.hpp.

◆ pool

template<generic_traits::return_data RD, class TPB, template< class > class Del, template< class > class AtCtr>
thread_pool_type& jmmcg::ppd::private_::horizontal_execution< RD, TPB, Del, AtCtr >::pool
protected

Definition at line 850 of file thread_client_context.hpp.


The documentation for this class was generated from the following file:
jmmcg::ppd::generic_traits::memory_access_modes::erew_memory_access
Exclusive-Read, Exclusive-Write memory access.
jmmcg::ppd::generic_traits::memory_access_modes::crew_memory_access
Concurrent-Read, Exclusive-Write memory access.
jmmcg::ppd::private_::horizontal_execution_itf::memory_access_mode
static constexpr ppd::generic_traits::memory_access_modes memory_access_mode
Definition: thread_client_context.hpp:379