Thread
Thread
#include <icy/thread.h>Inherits:
Runner
Platform-independent wrapper around an operating system thread.
This class inherits the [Runner](icy-Runner.html#runner) interface and may be used with any implementation that's powered by an asynchronous [Runner](icy-Runner.html#runner).
Public Methods
| Return | Name | Description |
|---|---|---|
Thread | Default constructor. | |
Thread inline explicit | Constructs a [Thread](#thread) and immediately starts it with the given function and arguments. | |
~Thread virtual | Destructor. | |
void | start inline | Starts the thread with a variadic function and arguments. The thread is started immediately; the previous thread must have exited before calling again. |
void | start virtual | Starts the thread with a std::function callback. Overrides [Runner::start](icy-Runner.html#start-3); delegates to the variadic start template. |
void | join | Wait until the thread exits. |
std::thread::id | id const | Return the native thread handle. |
Thread
Thread()Default constructor.
Thread
inline explicit
template<typename Function, typename... Args> inline explicit Thread(Function && func, Args &&... args)Constructs a [Thread](#thread) and immediately starts it with the given function and arguments.
Parameters
FunctionCallable type.ArgsArgument types forwarded to the function.
Parameters
funcCallable to execute on the new thread.argsArguments forwarded tofunc.
~Thread
virtual
virtual ~Thread()Destructor.
start
inline
template<typename Function, typename... Args> inline void start(Function && func, Args &&... args)Starts the thread with a variadic function and arguments. The thread is started immediately; the previous thread must have exited before calling again.
Parameters
FunctionCallable type.ArgsArgument types forwarded to the function.
Parameters
funcCallable to execute on the new thread.argsArguments forwarded tofunc.
start
virtual
virtual void start(std::function< void()> func)Starts the thread with a std::function callback. Overrides [Runner::start](icy-Runner.html#start-3); delegates to the variadic start template.
Parameters
funcCallable to execute on the new thread.
join
void join()Wait until the thread exits.
id
const
std::thread::id id() constReturn the native thread handle.
Public Static Attributes
| Return | Name | Description |
|---|---|---|
const std::thread::id | mainID static | Accessor for the main thread ID. |
mainID
static
const std::thread::id mainIDAccessor for the main thread ID.
Public Static Methods
| Return | Name | Description |
|---|---|---|
std::thread::id | currentID static | Return the native thread ID of the current thread. |
currentID
static
static std::thread::id currentID()Return the native thread ID of the current thread.
Protected Attributes
| Return | Name | Description |
|---|---|---|
std::thread | _thread |
_thread
std::thread _threadProtected Methods
| Return | Name | Description |
|---|---|---|
Thread | NonCopyable and NonMovable. | |
Thread | Deleted constructor. | |
bool | async virtual const | Returns true if the implementation is thread-based. |
Thread
Thread(const Thread &) = deleteNonCopyable and NonMovable.
Thread
Thread(Thread &&) = deleteDeleted constructor.
async
virtual const
virtual bool async() constReturns true if the implementation is thread-based.
Returns
True for thread-backed runners, false for event-loop-driven runners.
Public Types
| Name | Description |
|---|---|
Ptr |
Ptr
std::shared_ptr< Thread > Ptr()