#include "lib/thread.hpp"
template<template< class, class > class POL, typename RES = void>
class lib::thread::ThreadLifecycle< POL, RES >
Policy-based configuration of thread lifecycle.
Definition at line 377 of file thread.hpp.
|
| ThreadLifecycle (Launch launcher) |
| Primary constructor: Launch the new thread with flexible configuration. More...
|
|
template<class FUN , typename... ARGS> |
| ThreadLifecycle (string const &threadID, FUN &&threadFunction, ARGS &&...args) |
| Create a new thread to execute the given operation. More...
|
|
template<class SUB , typename... ARGS> |
| ThreadLifecycle (RES(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...
|
|
|
template<class W , class... INVO> |
static auto | buildInvocation (W &wrapper, tuple< INVO... > &&invocation) |
| Build the invocation tuple, using #invokeThreadFunction to delegate to the user-provided functor and arguments.
|
|
template<class... INVO> |
static auto | buildLauncher (INVO &&...args) |
| Build a λ actually to launch the given thread operation later, after the thread-wrapper-object is fully initialised. More...
|
|
|
struct | Launch |
| Configuration builder to define the operation running within the thread, and possibly configure further details, depending on the actual Policy used. More...
|
|
|
template<typename... ARGS> |
void | invokeThreadFunction (ARGS &&...args) |
|
◆ ThreadLifecycle() [1/3]
Primary constructor: Launch the new thread with flexible configuration.
- Parameters
-
launcher | a #Launch builder with a λ-chain to configure and finally trigger start of the thread |
Definition at line 575 of file thread.hpp.
◆ ThreadLifecycle() [2/3]
ThreadLifecycle |
( |
string const & |
threadID, |
|
|
FUN && |
threadFunction, |
|
|
ARGS &&... |
args |
|
) |
| |
|
inline |
Create a new thread to execute the given operation.
The new thread starts up synchronously, can't be cancelled and it can't be joined.
- Parameters
-
threadID | human readable descriptor to identify the thread for diagnostics |
threadFunction | a functor holding the code to execute within the new thread. Any function-like entity or callable is acceptable; arguments can be given. |
- Warning
- The operation functor and all arguments will be copied into the new thread. The return from this constructor syncs-with the launch of the operation.
Definition at line 591 of file thread.hpp.
◆ ThreadLifecycle() [3/3]
Special variant to bind a subclass member function as thread operation.
- Warning
- potential race between thread function and subclass initialisation
Definition at line 602 of file thread.hpp.
◆ buildLauncher()
static auto buildLauncher |
( |
INVO &&... |
args | ) |
|
|
inlinestatic |
Build a λ actually to launch the given thread operation later, after the thread-wrapper-object is fully initialised.
The member function #invokeThreadFunction will be run as top-level within the new thread, possibly handling errors, but delegating to the user-provided actual thread-operation
- Parameters
-
args | a invokable + further arguments |
- Note
- the invokable and the arguments will be materialised/copied thereby decaying the given type; this is necessary, because these arguments must be copied into the new thread. This will fail to compile, if the given invokable can not be invoked with these copied (and decayed) arguments.
Definition at line 437 of file thread.hpp.
◆ operator bool()
Is this thread »active« and thus tied to OS resources?
- Note
- this implies some statefulness, which may contradict the RAII pattern.
- especially note the possibly for derived classes to create an empty Thread.
- moreover note that ThreadJoinable may have terminated, but still awaits
join()
.
Definition at line 620 of file thread.hpp.
The documentation for this class was generated from the following file: