libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
|
This class is used to implement a class that wraps using a thread, it is an alternative to using a thread pool to manage your threads. More...
#include <thread_wrapper.hpp>
Public Types | |
using | base_t = private_::thread_base< API, Mdl > |
using | thread_context_t = TWC |
using | lock_traits = typename base_t::lock_traits |
using | thread_traits = typename base_t::thread_traits |
using | os_traits = typename base_t::os_traits |
using | exception_type = typename os_traits::exception_type |
![]() | |
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 |
Static Public Attributes | |
static constexpr ppd::generic_traits::memory_access_modes | memory_access_mode |
![]() | |
static constexpr ppd::generic_traits::memory_access_modes | memory_access_mode =lock_traits::critical_section_type::memory_access_mode |
Protected Member Functions | |
__stdcall | wrapper (const typename thread_traits::api_params_type::suspend_period_ms ew_=50) noexcept(false) FORCE_INLINE |
__stdcall | wrapper (thread_context_t &&thread_context, const typename thread_traits::api_params_type::suspend_period_ms ew_=50) noexcept(false) FORCE_INLINE |
virtual bool __fastcall | pre_exit () noexcept(false) FORCE_INLINE |
The method used to determine if there has been a request for the thread to exit, and therefore finish processing work, called before attempting to process() a work item. More... | |
virtual bool __fastcall | worker_fn (thread_context_t &context) noexcept(false)=0 |
This is the main "work" function. Implement it to do some work in the thread. More... | |
thread_traits::api_params_type::states __fastcall | process () noexcept(false) override |
Override this function is you want to do some other work to signal the exit of the thread. More... | |
![]() | |
__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) |
Protected Attributes | |
std::atomic< bool > | exit_requested |
![]() | |
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 | |
![]() | |
const thread_traits::api_params_type::suspend_period_ms | exit_wait_period |
This class is used to implement a class that wraps using a thread, it is an alternative to using a thread pool to manage your threads.
Note that the most derived classes' dtor must call private_::thread_base::wait_thread_exit() in it's dtor to ensure that the thread goes out of scope before the object upon which it relies.
Definition at line 53 of file thread_wrapper.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >::base_t = private_::thread_base<API, Mdl> |
Definition at line 55 of file thread_wrapper.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >::exception_type = typename os_traits::exception_type |
Definition at line 60 of file thread_wrapper.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >::lock_traits = typename base_t::lock_traits |
Definition at line 57 of file thread_wrapper.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >::os_traits = typename base_t::os_traits |
Definition at line 59 of file thread_wrapper.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >::thread_context_t = TWC |
Definition at line 56 of file thread_wrapper.hpp.
using jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >::thread_traits = typename base_t::thread_traits |
Definition at line 58 of file thread_wrapper.hpp.
|
inlinenoexcept |
Create the wrapper object. Note that the underlying kernel thread will not have been created.
Definition at line 40 of file thread_wrapper_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >::wrapper().
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >::wrapper().
|
inlineoverridenoexcept |
Definition at line 57 of file thread_wrapper_impl.hpp.
|
delete |
|
inlineexplicitprotectednoexcept |
Definition at line 30 of file thread_wrapper_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >::wrapper().
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >::wrapper().
|
inlineexplicitprotectednoexcept |
Definition at line 35 of file thread_wrapper_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >::wrapper().
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::wrapper< API, Mdl, TWC >::wrapper().
|
delete |
|
delete |
|
inlineprotectedvirtualnoexcept |
The method used to determine if there has been a request for the thread to exit, and therefore finish processing work, called before attempting to process() a work item.
Definition at line 45 of file thread_wrapper_impl.hpp.
|
inlineoverrideprotectedvirtualnoexcept |
Override this function is you want to do some other work to signal the exit of the thread.
This is primarily used by the destructor to politely tell the thread function to quit. Note that if you override this function you must still implement the exit functionality, otherwise the destructor will time-out and terminate the worker thread.
Implements jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::private_::thread_base< API, Mdl >.
Definition at line 50 of file thread_wrapper_impl.hpp.
|
protectedpure virtualnoexcept |
This is the main "work" function. Implement it to do some work in the thread.
context | The context is non-const, to allow the client to modify the state of the context, if they need to. (Although this generalisation may be really required....) |
|
mutableprotected |
Definition at line 88 of file thread_wrapper.hpp.
|
staticconstexpr |
To assist in allowing compile-time computation of the algorithmic order of the threading model.
Definition at line 65 of file thread_wrapper.hpp.