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.
|
| |
| template<class FUN , typename... ARGS> |
| | ThreadLifecycle (string const &threadID, FUN &&threadFunction, ARGS &&...args) |
| | Create a new thread to execute the given operation.
|
| |
| template<class SUB , typename... ARGS> |
| | ThreadLifecycle (RES(SUB::*memFun)(ARGS...), ARGS ...args) |
| | Special variant to bind a subclass member function as thread operation.
|
| |
| | operator bool () const |
| | Is this thread »active« and thus tied to OS resources?
|
| |
template<template< class, class > class POL, typename RES = void>
template<class FUN , typename... ARGS>
| 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.
template<template< class, class > class POL, typename RES = void>
template<class SUB , typename... ARGS>
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.
template<template< class, class > class POL, typename RES = void>
template<class W , class... INVO>
| static auto buildInvocation |
( |
W & |
wrapper, |
|
|
tuple< INVO... > && |
invocation |
|
) |
| |
|
inlinestatic |
template<template< class, class > class POL, typename RES = void>
template<class... INVO>
| 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.
References ThreadLifecycle< POL, RES >::buildInvocation().