Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
ThreadJoinable< RES > Class Template Reference

#include "lib/thread.hpp"

Description

template<typename RES = void>
class lib::ThreadJoinable< RES >

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.

Warning
Thread must be joined prior to destructor invocation, otherwise the application is shut down immediately via 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
 
- Public Member Functions inherited from ThreadLifecycle< POL, RES >
 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?
 

Private Types

using Impl = thread::ThreadLifecycle< thread::PolicyResultJoin, RES >
 

Additional Inherited Members

- Static Public Member Functions inherited from ThreadLifecycle< POL, RES >
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.
 
- Protected Member Functions inherited from ThreadLifecycle< POL, RES >
 ~ThreadLifecycle ()
 
 ThreadLifecycle ()
 derived classes may create a disabled thread
 

Member Typedef Documentation

◆ Impl

template<typename RES = void>
using Impl = thread::ThreadLifecycle<thread::PolicyResultJoin, RES>
private

Definition at line 671 of file thread.hpp.

Member Function Documentation

◆ join()

template<typename RES = void>
lib::Result< RES > join ( )
inline

put the caller into a blocking wait until this thread has terminated

Returns
intermediary token signalling either success or failure. The caller can find out by invoking 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.

Referenced by DummyTickService::~DummyTickService(), SessionCommandFunction_test::perform_massivelyParallel(), SyncClasslock_test::run(), IncidenceCount_test::verify_concurrencyStatistic(), DiagnosticContext_test::verify_heavilyParallelUsage(), and CallQueue_test::verify_ThreadSafety().

+ Here is the caller graph for this function:
+ Inheritance diagram for ThreadJoinable< RES >:
+ Collaboration diagram for ThreadJoinable< RES >:

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