#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).
| 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()Default constructor.
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.
Function Callable type.
Args Argument types forwarded to the function.
func Callable to execute on the new thread.
args Arguments forwarded to func.
virtual
virtual ~Thread()Destructor.
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.
Function Callable type.
Args Argument types forwarded to the function.
func Callable to execute on the new thread.
args Arguments forwarded to func.
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.
func Callable to execute on the new thread.void join()Wait until the thread exits.
const
std::thread::id id() constReturn the native thread handle.
| Return | Name | Description |
|---|---|---|
const std::thread::id | mainID static | Accessor for the main thread ID. |
static
const std::thread::id mainIDAccessor for the main thread ID.
| Return | Name | Description |
|---|---|---|
std::thread::id | currentID static | Return the native thread ID of the current thread. |
static
static std::thread::id currentID()Return the native thread ID of the current thread.
| Return | Name | Description |
|---|---|---|
std::thread | _thread |
std::thread _thread| Return | Name | Description |
|---|---|---|
Thread | NonCopyable and NonMovable. | |
Thread | Deleted constructor. | |
bool | async virtual const | Returns true if the implementation is thread-based. |
Thread(const Thread &) = deleteNonCopyable and NonMovable.
Thread(Thread &&) = deleteDeleted constructor.
virtual const
virtual bool async() constReturns true if the implementation is thread-based.
True for thread-backed runners, false for event-loop-driven runners.
| Name | Description |
|---|---|
Ptr |
std::shared_ptr< Thread > Ptr()