Lumiera  0.pre.03
»edit your freedom«
ThreadHookable Class Reference

#include "lib/thread.hpp"

Description

Extended variant of the standard case, allowing to install callbacks (hook functions) to be invoked during thread lifecycle:

  • atStart : invoked as first user code in the new thread
  • atExit : invoked as the last user code prior to detaching and thread end
  • onOrphan : invoked from the thread-wrapper destructor, when the actual thread is detected as still running (according to the thread handle) By default, these callbacks are empty; custom callbacks can be installed through the ThreadLifecycle::Launch configuration builder using the corresponding builder functions (e.g. .atExit(λ)). The passed functor can either take no argument, or a single argument with a reference to some *this subtype, which must be reachable by static downcast from the ThreadLifecycle base type.

Definition at line 724 of file thread.hpp.

Additional Inherited Members

- Public Member Functions inherited from ThreadLifecycle< thread::PolicyLifecycleHook >
 ThreadLifecycle (Launch launcher)
 Primary constructor: Launch the new thread with flexible configuration. More...
 
 ThreadLifecycle (string const &threadID, FUN &&threadFunction, ARGS &&...args)
 Create a new thread to execute the given operation. More...
 
 ThreadLifecycle (void(SUB::*memFun)(ARGS...), ARGS ...args)
 Special variant to bind a subclass member function as thread operation. More...
 
 operator bool () const
 Is this thread »active« and thus tied to OS resources? More...
 
- Static Public Member Functions inherited from ThreadLifecycle< thread::PolicyLifecycleHook >
static auto buildInvocation (W &wrapper, tuple< INVO... > &&invocation)
 Build the invocation tuple, using #invokeThreadFunction to delegate to the user-provided functor and arguments.
 
static auto buildLauncher (INVO &&...args)
 Build a λ actually to launch the given thread operation later, after the thread-wrapper-object is fully initialised. More...
 
- Protected Types inherited from PolicyLifecycleHook< ThreadWrapper, void >
using BasePol = PolicyLaunchOnly< ThreadWrapper >
 
using Hook = function< void(Self &)>
 
using Self = PolicyLifecycleHook
 
- Protected Member Functions inherited from ThreadLifecycle< thread::PolicyLifecycleHook >
 ThreadLifecycle ()
 derived classes may create a disabled thread
 
- Protected Member Functions inherited from PolicyLifecycleHook< ThreadWrapper, void >
void handle_after_thread ()
 
void handle_begin_thread ()
 
void handle_loose_thread ()
 
- Protected Member Functions inherited from PolicyLaunchOnly< ThreadWrapper >
void handle_after_thread ()
 
void handle_loose_thread ()
 
void perform_thread_function (FUN &&callable, ARGS &&...args)
 
- Protected Member Functions inherited from ThreadWrapper
 ThreadWrapper ()
 
 ThreadWrapper (string const &threadID)
 
void detach_thread_from_wrapper ()
 allow to detach explicitly — independent from thread-function's state. More...
 
void handle_after_thread ()
 called immediately before end of thread
 
void handle_begin_thread ()
 called immediately at start of thread
 
void handle_loose_thread ()
 called when destroying wrapper on still running thread
 
bool invokedWithinThread () const
 detect if the currently executing code runs within this thread More...
 
bool isLive () const
 
template<class... INVO>
void launchThread (tuple< INVO... > &&invocation)
 
void markThreadEnd ()
 
void markThreadStart ()
 
void setThreadName ()
 
void waitGracePeriod () noexcept
 
- Protected Member Functions inherited from MoveOnly
 MoveOnly (MoveOnly &&)=default
 
 MoveOnly (MoveOnly const &)=delete
 
MoveOnlyoperator= (MoveOnly &&)=delete
 
MoveOnlyoperator= (MoveOnly const &)=delete
 
- Static Protected Member Functions inherited from ThreadWrapper
static string decorate_with_global_count (string const &)
 Helper to create a suffix to the thread-ID with running count.
 
- Protected Attributes inherited from PolicyLifecycleHook< ThreadWrapper, void >
Hook hook_afterThread
 
Hook hook_beginThread
 
Hook hook_looseThread
 
- Protected Attributes inherited from ThreadWrapper
const string threadID_
 
std::thread threadImpl_
 
+ Inheritance diagram for ThreadHookable:
+ Collaboration diagram for ThreadHookable:

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