libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
|
This class is used to implement a raw class that wraps using a raw thread. More...
#include <thread_base.hpp>
Public Types | |
typedef thread_os_traits< API, Mdl > | os_traits |
typedef os_traits::thread_traits | thread_traits |
typedef os_traits::lock_traits | lock_traits |
typedef os_traits::exception_type | exception_type |
Public Attributes | |
const thread_traits::api_params_type::suspend_period_ms | exit_wait_period |
Static Public Attributes | |
static constexpr ppd::generic_traits::memory_access_modes | memory_access_mode =lock_traits::critical_section_type::memory_access_mode |
Protected Member Functions | |
__stdcall | thread_base (const typename thread_traits::api_params_type::suspend_period_ms exit_wait_p) noexcept(false) |
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) |
virtual __stdcall | ~thread_base () noexcept(false) |
Thread base dtor. More... | |
void __fastcall | wait_thread_exit () noexcept(false) |
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 | |
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 |
This class is used to implement a raw class that wraps using a raw thread.
This provides the thread-as-an-active-class threading model.
Definition at line 32 of file thread_base.hpp.
typedef os_traits::exception_type jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::exception_type |
Definition at line 37 of file thread_base.hpp.
typedef os_traits::lock_traits jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::lock_traits |
Definition at line 36 of file thread_base.hpp.
typedef thread_os_traits<API, Mdl> jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::os_traits |
Definition at line 34 of file thread_base.hpp.
typedef os_traits::thread_traits jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_traits |
Definition at line 35 of file thread_base.hpp.
|
inlineexplicitprotectednoexcept |
Create the wrapper object. Note that the underlying kernel thread will not have been started.
exit_wait_p | The length of time, in ms, that the dtor will wait for the thread to exit before terminating the thread. Such termination may cause undefined behaviour to result, depending upon the details of how the underlying OS manages thread termination. |
Definition at line 153 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::exit_wait_period, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
inlineexplicitprotectednoexcept |
Definition at line 160 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::exception_thrown_in_thread, jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::exit_wait_period, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
inlineprotectedvirtualnoexcept |
Thread base dtor.
Don't throw any registered "exception_thrown_in_thread" here, because evil leaks will happen in the thread pool. YUCK. Ignore any bad exit states from the thread too. Tough. Ensure that wait_thread_exit() is called from the most-derived dtor, otherwise UB will happen.
Definition at line 167 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
inlinevirtualnoexcept |
Start the underlying kernel thread.
Definition at line 78 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params_lock.
|
inlinenoexcept |
Definition at line 26 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
inlinenoexcept |
Definition at line 125 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
inlinenoexcept |
Definition at line 131 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
inlinenoexcept |
Definition at line 112 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
inlinenoexcept |
Definition at line 118 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
inlinenoexcept |
Definition at line 48 of file thread_base.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
protectedpure virtualnoexcept |
This is the main "work" function. Implement it to do some work in the thread.
Any exceptions thrown will be caught in the core_work_fn() and reported to the user (or calling thread) by re-throwing, at the latest, in the destructor.
Implemented in jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >, jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< os_traits::thread_traits::api_params_type::api_type, os_traits::thread_traits::model_type >, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, std::function< void()> >.
|
inlinevirtualnoexcept |
We don't gobble exceptions, because thread_pools might want to know if a member fails... TODO Is this true?: Note that if this method throws an exception, wait_thread_exit() may lock up unless the situation is managed further.
Definition at line 198 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
inlinenoexcept |
Definition at line 67 of file thread_base_impl.hpp.
|
inlinenoexcept |
Definition at line 137 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
inlinenoexcept |
|
noexcept |
|
inlinevirtualnoexcept |
Reimplemented in jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::pool::private_::pool_thread< OST, ExitReq >, jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::pool::private_::pool_thread< thread_os_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >, PTT::template pool_thread_queue_details< pool_traits::work_distribution_mode_t::queue_model_t::pool_owns_queue >::exit_requested_type >, jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::pool::private_::pool_thread< thread_os_traits< generic_traits::api_type::posix_pthreads, sequential_mode >, PTT::template pool_thread_queue_details< pool_traits::work_distribution_mode_t::queue_model_t::pool_owns_queue >::exit_requested_type >, jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::pool::private_::pool_thread< thread_os_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >, PTT::template pool_thread_queue_details< 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 > >::exit_requested_type >, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::pool::private_::pool_thread< thread_os_traits< generic_traits::api_type::posix_pthreads, sequential_mode >, PTT::template pool_thread_queue_details< QM >::exit_requested_type >.
Definition at line 143 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::exception_thrown_in_thread, jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::exit_wait_period, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
inlineprotectednoexcept |
This must be called from the most-derived class, otherwise you could get "pure virtual call" errors, because process() could be called, or other dependent class members could be deleted before the thread exists.
Definition at line 175 of file thread_base_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::exit_wait_period, and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_params.
|
protected |
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.
Definition at line 73 of file thread_base.hpp.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_base(), and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::to_string().
const thread_traits::api_params_type::suspend_period_ms jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::exit_wait_period |
Definition at line 44 of file thread_base.hpp.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_base(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::to_string(), and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::wait_thread_exit().
|
staticconstexpr |
To assist in allowing compile-time computation of the algorithmic order of the threading model.
Definition at line 42 of file thread_base.hpp.
|
mutableprotected |
Definition at line 76 of file thread_base.hpp.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::create_running(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::is_running(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::kernel_affinity(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::kernel_priority(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::params(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::request_exit(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::set_name(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::state(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::thread_base(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::to_string(), jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::wait_thread_exit(), and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::~thread_base().
|
mutableprotected |
Definition at line 75 of file thread_base.hpp.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::create_running(), and jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >::state().