![]() |
Lumiera
0.pre.03
»edit your freedom«
|
#include "lib/thread.hpp"
Variant of the standard case, requiring to wait and join()
on the termination of this thread.
Useful to collect results calculated by multiple threads. Note however that the system resources of the thread are kept around until the join()
call, and thus also the bool
conversion yields true
, even while the actual operation has already terminated.
std::terminate
. Definition at line 668 of file thread.hpp.
Public Member Functions | |
lib::Result< RES > | join () |
put the caller into a blocking wait until this thread has terminated More... | |
![]() | |
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 (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... | |
Private Types | |
using | Impl = thread::ThreadLifecycle< thread::PolicyResultJoin, RES > |
Additional Inherited Members | |
![]() | |
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... | |
![]() | |
ThreadLifecycle () | |
derived classes may create a disabled thread | |
![]() | |
void | handle_after_thread () |
void | handle_loose_thread () |
void | perform_thread_function (FUN &&callable, ARGS &&...args) |
![]() | |
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 |
![]() | |
MoveOnly (MoveOnly &&)=default | |
MoveOnly (MoveOnly const &)=delete | |
MoveOnly & | operator= (MoveOnly &&)=delete |
MoveOnly & | operator= (MoveOnly const &)=delete |
![]() | |
static string | decorate_with_global_count (string const &) |
Helper to create a suffix to the thread-ID with running count. | |
![]() | |
lib::Result< RES > | result_ |
Wrapper to capture a success/failure indicator and possibly a computation result. | |
![]() | |
const string | threadID_ |
std::thread | threadImpl_ |
|
inline |
put the caller into a blocking wait until this thread has terminated
isValid()
or maybeThrow()
on this result token. Moreover, if the thread function yields a result value, this value is copied into the token and can be retrieved either by type conversion, or with get<TY>()
, value_or(default)
or even with an alternative producer or_else(λ)
. Definition at line 685 of file thread.hpp.