libjmmcg  release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl > Struct Template Reference

#include <thread_api_traits.hpp>

Classes

struct  cancellability
 

Public Types

typedef thread_params< API > api_params_type
 
typedef api_lock_traits< API, Mdl > lock_traits
 
typedef Mdl model_type
 
using demangled_name_t = std::array< char, 16384 >
 An unmangled name surely can't be longer than 16k?! More...
 
typedef std::array< char, max_num_fn_ptrs *sizeof(demangled_name_t)> demangled_names_t
 And this struct would never be larger than the stack size we've allowed in a thread, surely?! More...
 

Public Member Functions

api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::api_params_type::pid_type __fastcall get_current_process_id () noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::api_params_type::tid_type __fastcall get_current_thread_id () noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::api_params_type::handle_type __fastcall get_current_thread () noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::api_params_type::username_type __fastcall get_current_username () noexcept(true)
 
void __fastcall demangle_name (char const *const mangled_name, demangled_name_t &demangled_name) noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::demangled_name_t __fastcall demangle_name (std::type_info const &mangled_type) noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::demangled_names_t __fastcall gen_backtrace () noexcept(true)
 
void __fastcall set_backtrace_on_signal () noexcept(true)
 
void __fastcall set_backtrace_on_terminate () noexcept(true)
 
void __fastcall set_name (typename api_params_type::handle_type, char const *) noexcept(false)
 
void __fastcall raise (int sig) noexcept(true)
 
bool __fastcall create (const api_params_type::creation_flags creflag, api_params_type &parms) noexcept(true)
 Run the work only once if it returns at all, unlike the multi-threaded variant. More...
 
api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::api_params_type::suspend_count __fastcall suspend (api_params_type const &) noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::api_params_type::suspend_count __fastcall resume (api_params_type const &parms) noexcept(true)
 This does not run the work at all, unlike the multi-threaded variant. More...
 
api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::api_params_type::states __fastcall state (api_params_type &) noexcept(true)
 
void __fastcall exit (api_params_type::states &) noexcept(true)
 
void __fastcall terminate (api_params_type::handle_type) noexcept(false)
 
void __fastcall cleanup (api_params_type::handle_type) noexcept(false)
 
void __fastcall set_kernel_priority (api_params_type::handle_type, const api_params_type::priority_type) noexcept(false)
 
void __fastcall set_kernel_affinity (typename api_params_type::handle_type const, const api_params_type::processor_mask_type) noexcept(false)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::api_params_type::processor_mask_type __fastcall get_kernel_affinity (typename api_params_type::handle_type const) noexcept(false)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::api_params_type::priority_type __fastcall get_kernel_priority (api_params_type::handle_type) noexcept(false)
 
void __fastcall set_cancelstate (api_params_type::thread_cancel_state) noexcept(false)
 
void __fastcall sleep (const api_params_type::suspend_period_ms) noexcept(false)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::api_params_type::states __fastcall wait_thread_exit (api_params_type &, const lock_traits::timeout_type) noexcept(false)
 
void __fastcall raise (int sig) noexcept(true)
 
bool create (const api_params_type::creation_flags, api_params_type &cp) noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >::api_params_type::suspend_count suspend (api_params_type const &) noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >::api_params_type::suspend_count resume (api_params_type const &) noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >::api_params_type::states state (api_params_type &thread) noexcept(true)
 
bool __fastcall is_running (api_params_type &thread) noexcept(true)
 
void exit (api_params_type::states &exit_code) noexcept(true)
 
void __fastcall set_cancelstate (api_params_type::thread_cancel_state state) noexcept(false)
 
void terminate (api_params_type::handle_type thread) noexcept(false)
 
void cleanup (api_params_type::handle_type thread) noexcept(false)
 
void set_kernel_priority (api_params_type::handle_type, const api_params_type::priority_type priority) noexcept(false)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >::api_params_type::priority_type get_kernel_priority (api_params_type::handle_type thread) noexcept(false)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >::api_params_type::pid_type get_current_process_id () noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >::api_params_type::tid_type get_current_thread_id () noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >::api_params_type::handle_type get_current_thread () noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >::api_params_type::username_type __fastcall get_current_username () noexcept(true)
 
void __fastcall set_kernel_affinity (typename api_params_type::handle_type const thread_id, api_params_type::processor_mask_type const mask) noexcept(false)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >::api_params_type::processor_mask_type __fastcall get_kernel_affinity (typename api_params_type::handle_type const thread_id) noexcept(false)
 
void sleep (const api_params_type::suspend_period_ms period) noexcept(false)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >::api_params_type::states wait_thread_exit (api_params_type &thread, const lock_traits::timeout_type) noexcept(false)
 
void __fastcall demangle_name (char const *const mangled_name, demangled_name_t &demangled_name) noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >::demangled_name_t __fastcall demangle_name (std::type_info const &mangled_type) noexcept(true)
 
api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::demangled_names_t __fastcall gen_backtrace () noexcept(true)
 
void __fastcall set_backtrace_on_signal () noexcept(true)
 
void __fastcall set_backtrace_on_terminate () noexcept(true)
 
void __fastcall set_name (typename api_params_type::handle_type thread, char const *name) noexcept(false)
 

Static Public Member Functions

static void raise (int sig) noexcept(true)
 
static bool __fastcall create (const typename api_params_type::creation_flags creflag, api_params_type &) noexcept(true) FORCE_INLINE
 Create a new OS-level thread of the appropriate type. More...
 
static api_params_type::suspend_count __fastcall suspend (api_params_type const &) noexcept(true) FORCE_INLINE
 
static api_params_type::suspend_count __fastcall resume (api_params_type const &) noexcept(true) FORCE_INLINE
 
static api_params_type::states __fastcall state (api_params_type &) noexcept(true) FORCE_INLINE
 
static bool __fastcall is_running (api_params_type &) noexcept(true) FORCE_INLINE
 
static void __fastcall exit (typename api_params_type::states &) noexcept(true) FORCE_INLINE
 Exit the currently running thread. More...
 
static void __fastcall terminate (typename api_params_type::handle_type) noexcept(false) FORCE_INLINE
 Request or force that the target thread exit. More...
 
static void __fastcall cleanup (typename api_params_type::handle_type) noexcept(false) FORCE_INLINE
 Ensure that any possible clean up that may need to be done of thread state may be performed after the thread has exited. More...
 
static void __fastcall set_kernel_priority (typename api_params_type::handle_type, const typename api_params_type::priority_type) noexcept(false) FORCE_INLINE
 
static api_params_type::priority_type __fastcall get_kernel_priority (typename api_params_type::handle_type) noexcept(false) FORCE_INLINE
 
static void __fastcall set_kernel_affinity (typename api_params_type::handle_type const, typename api_params_type::processor_mask_type const) noexcept(false) FORCE_INLINE
 
static api_params_type::processor_mask_type __fastcall get_kernel_affinity (typename api_params_type::handle_type const) noexcept(false) FORCE_INLINE
 
static api_params_type::pid_type __fastcall get_current_process_id () noexcept(true) FORCE_INLINE
 
static api_params_type::tid_type __fastcall get_current_thread_id () noexcept(true) FORCE_INLINE
 
static api_params_type::handle_type __fastcall get_current_thread () noexcept(true) FORCE_INLINE
 
static api_params_type::username_type __fastcall get_current_username () noexcept(true) FORCE_INLINE
 
static void __fastcall set_cancelstate (typename api_params_type::thread_cancel_state state) noexcept(false) FORCE_INLINE
 
static void __fastcall sleep (const typename api_params_type::suspend_period_ms period) noexcept(false) FORCE_INLINE
 Sort-of threading, as it suspends the current thread of execution. More...
 
static api_params_type::states __fastcall wait_thread_exit (api_params_type &, const typename lock_traits::timeout_type period) noexcept(false) FORCE_INLINE
 
static void __fastcall demangle_name (char const *const mangled_name, demangled_name_t &demangled_name) noexcept(true)
 Attempt to demangle a potentially mangled C++ identifier. More...
 
static demangled_name_t __fastcall demangle_name (std::type_info const &mangled_type) noexcept(true)
 
static demangled_names_t __fastcall gen_backtrace () noexcept(true)
 Return a string containing the current backtrace, with demangled names, separated by "\n". More...
 
static void __fastcall set_backtrace_on_signal () noexcept(true)
 Dump a backtrace to std::cerr if SIGABRT is raised, once this function is called. More...
 
static void __fastcall set_backtrace_on_terminate () noexcept(true)
 Dump a backtrace to std::cerr if std::terminate is called, once this function is called. More...
 
static void __fastcall set_name (typename api_params_type::handle_type, char const *name) noexcept(false)
 

Static Public Attributes

static constexpr int max_num_fn_ptrs =100
 100 functions in the stack frame should be enough for anyone... Eeek! More...
 

Detailed Description

template<generic_traits::api_type API, typename Mdl>
struct jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >

Definition at line 233 of file thread_api_traits.hpp.

Member Typedef Documentation

◆ api_params_type

Definition at line 234 of file thread_api_traits.hpp.

◆ demangled_name_t

template<generic_traits::api_type API, typename Mdl >
using jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::demangled_name_t = std::array<char, 16384>

An unmangled name surely can't be longer than 16k?!

Definition at line 238 of file thread_api_traits.hpp.

◆ demangled_names_t

And this struct would never be larger than the stack size we've allowed in a thread, surely?!

Definition at line 242 of file thread_api_traits.hpp.

◆ lock_traits

Definition at line 235 of file thread_api_traits.hpp.

◆ model_type

Definition at line 236 of file thread_api_traits.hpp.

Member Function Documentation

◆ cleanup() [1/3]

◆ cleanup() [2/3]

◆ cleanup() [3/3]

template<generic_traits::api_type API, typename Mdl >
static void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::cleanup ( typename api_params_type::handle_type  )
staticnoexcept

Ensure that any possible clean up that may need to be done of thread state may be performed after the thread has exited.

◆ create() [1/3]

Run the work only once if it returns at all, unlike the multi-threaded variant.

If the worker_fn() returns true then it will run once, then exit, otherwise it will depend upon the return value for pre_exit(). If this always returns false, then the system will enter an infinite loop. By default pre_exit() for sequential mode returns false.

See also
worker_fn(), process()

Definition at line 235 of file thread_api_traits_impl.hpp.

◆ create() [2/3]

◆ create() [3/3]

template<generic_traits::api_type API, typename Mdl >
static bool __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::create ( const typename api_params_type::creation_flags  creflag,
api_params_type  
)
staticnoexcept

Create a new OS-level thread of the appropriate type.

Returns
true is the OS-level thread was successfully created, false otherwise.

◆ demangle_name() [1/6]

template<generic_traits::api_type API, typename Mdl >
static void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::demangle_name ( char const *const  mangled_name,
demangled_name_t demangled_name 
)
staticnoexcept

Attempt to demangle a potentially mangled C++ identifier.

◆ demangle_name() [2/6]

void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< generic_traits::api_type::posix_pthreads, sequential_mode >::demangle_name ( char const *const  mangled_name,
demangled_name_t demangled_name 
)
inlinenoexcept

Definition at line 54 of file thread_api_traits_impl.hpp.

◆ demangle_name() [3/6]

void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< generic_traits::api_type::posix_pthreads, heavyweight_threading >::demangle_name ( char const *const  mangled_name,
demangled_name_t demangled_name 
)
inlinenoexcept

Definition at line 564 of file thread_api_traits_impl.hpp.

◆ demangle_name() [4/6]

template<generic_traits::api_type API, typename Mdl >
static demangled_name_t __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::demangle_name ( std::type_info const &  mangled_type)
staticnoexcept

◆ demangle_name() [5/6]

◆ demangle_name() [6/6]

◆ exit() [1/3]

◆ exit() [2/3]

◆ exit() [3/3]

template<generic_traits::api_type API, typename Mdl >
static void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::exit ( typename api_params_type::states )
staticnoexcept

Exit the currently running thread.

◆ gen_backtrace() [1/3]

template<generic_traits::api_type API, typename Mdl >
static demangled_names_t __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::gen_backtrace ( )
staticnoexcept

Return a string containing the current backtrace, with demangled names, separated by "\n".

Todo:
Reimplement with:

◆ gen_backtrace() [2/3]

◆ gen_backtrace() [3/3]

◆ get_current_process_id() [1/3]

◆ get_current_process_id() [2/3]

◆ get_current_process_id() [3/3]

template<generic_traits::api_type API, typename Mdl >
static api_params_type::pid_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::get_current_process_id ( )
staticnoexcept

◆ get_current_thread() [1/3]

◆ get_current_thread() [2/3]

◆ get_current_thread() [3/3]

template<generic_traits::api_type API, typename Mdl >
static api_params_type::handle_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::get_current_thread ( )
staticnoexcept

◆ get_current_thread_id() [1/3]

◆ get_current_thread_id() [2/3]

◆ get_current_thread_id() [3/3]

◆ get_current_username() [1/3]

◆ get_current_username() [2/3]

◆ get_current_username() [3/3]

template<generic_traits::api_type API, typename Mdl >
static api_params_type::username_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::get_current_username ( )
staticnoexcept

◆ get_kernel_affinity() [1/3]

◆ get_kernel_affinity() [2/3]

◆ get_kernel_affinity() [3/3]

template<generic_traits::api_type API, typename Mdl >
static api_params_type::processor_mask_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::get_kernel_affinity ( typename api_params_type::handle_type const  )
staticnoexcept

◆ get_kernel_priority() [1/3]

◆ get_kernel_priority() [2/3]

◆ get_kernel_priority() [3/3]

template<generic_traits::api_type API, typename Mdl >
static api_params_type::priority_type __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::get_kernel_priority ( typename api_params_type::handle_type  )
staticnoexcept

◆ is_running() [1/2]

◆ is_running() [2/2]

◆ raise() [1/3]

template<generic_traits::api_type API, typename Mdl >
static void jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::raise ( int  sig)
staticnoexcept

◆ raise() [2/3]

◆ raise() [3/3]

◆ resume() [1/3]

◆ resume() [2/3]

◆ resume() [3/3]

◆ set_backtrace_on_signal() [1/3]

template<generic_traits::api_type API, typename Mdl >
static void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::set_backtrace_on_signal ( )
staticnoexcept

Dump a backtrace to std::cerr if SIGABRT is raised, once this function is called.

◆ set_backtrace_on_signal() [2/3]

◆ set_backtrace_on_signal() [3/3]

◆ set_backtrace_on_terminate() [1/3]

template<generic_traits::api_type API, typename Mdl >
static void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::set_backtrace_on_terminate ( )
staticnoexcept

Dump a backtrace to std::cerr if std::terminate is called, once this function is called.

◆ set_backtrace_on_terminate() [2/3]

◆ set_backtrace_on_terminate() [3/3]

◆ set_cancelstate() [1/3]

◆ set_cancelstate() [2/3]

◆ set_cancelstate() [3/3]

◆ set_kernel_affinity() [1/3]

◆ set_kernel_affinity() [2/3]

◆ set_kernel_affinity() [3/3]

template<generic_traits::api_type API, typename Mdl >
static void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::set_kernel_affinity ( typename api_params_type::handle_type const  ,
typename api_params_type::processor_mask_type const   
)
staticnoexcept

◆ set_kernel_priority() [1/3]

◆ set_kernel_priority() [2/3]

◆ set_kernel_priority() [3/3]

template<generic_traits::api_type API, typename Mdl >
static void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::set_kernel_priority ( typename api_params_type::handle_type  ,
const typename api_params_type::priority_type   
)
staticnoexcept

◆ set_name() [1/3]

◆ set_name() [2/3]

◆ set_name() [3/3]

template<generic_traits::api_type API, typename Mdl >
static void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::set_name ( typename api_params_type::handle_type  ,
char const *  name 
)
staticnoexcept

◆ sleep() [1/3]

◆ sleep() [2/3]

◆ sleep() [3/3]

template<generic_traits::api_type API, typename Mdl >
static void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::sleep ( const typename api_params_type::suspend_period_ms  period)
staticnoexcept

Sort-of threading, as it suspends the current thread of execution.

Parameters
periodThe period to sleep in ms. A value of zero should cause the thread to yield, so that it is no longer in a running state. (The rest of its time-slice is re-scheduled to run at some later period.)

◆ state() [1/3]

◆ state() [2/3]

◆ state() [3/3]

◆ suspend() [1/3]

◆ suspend() [2/3]

◆ suspend() [3/3]

◆ terminate() [1/3]

◆ terminate() [2/3]

◆ terminate() [3/3]

template<generic_traits::api_type API, typename Mdl >
static void __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::terminate ( typename api_params_type::handle_type  )
staticnoexcept

Request or force that the target thread exit.

Note that this may result in undefined behaviour depending upon how the underlying OS copes with cleaning the state loaded by the thread.

◆ wait_thread_exit() [1/3]

◆ wait_thread_exit() [2/3]

template<generic_traits::api_type API, typename Mdl >
static api_params_type::states __fastcall jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::wait_thread_exit ( api_params_type ,
const typename lock_traits::timeout_type  period 
)
staticnoexcept

◆ wait_thread_exit() [3/3]

Member Data Documentation

◆ max_num_fn_ptrs

template<generic_traits::api_type API, typename Mdl >
constexpr int jmmcg::LIBJMMCG_VER_NAMESPACE::ppd::api_threading_traits< API, Mdl >::max_num_fn_ptrs =100
staticconstexpr

100 functions in the stack frame should be enough for anyone... Eeek!

Definition at line 240 of file thread_api_traits.hpp.


The documentation for this struct was generated from the following files: