Provides an OOP interface to the Eina_Thread
and automatic resource allocation and deallocation using the RAII programming idiom.
More...
Public Types | |
typedef thread_id | id |
Type for the thread identifier. More... | |
typedef Eina_Thread | native_handle_type |
Type for the native Eina_Thread handle. More... | |
Public Member Functions | |
thread () noexcept | |
Creates a thread object that does not represent any thread of execution. | |
template<typename F , class ... Args> | |
thread (F &&f, Args &&... args) | |
Creates a thread of execution. More... | |
thread (thread &&other) | |
Move constructor. More... | |
thread & | operator= (thread &&other) |
Transfer the thread of execution. More... | |
~thread () | |
Destroys the thread object. | |
void | swap (thread &other) noexcept |
Exchanges the underlying handles of two thread objects. More... | |
bool | joinable () const noexcept |
Check if the thread object identifies an active thread of execution. More... | |
void | join () |
Wait for the thread to finish its execution. More... | |
void | detach () |
Detaches the thread from its handle, making it runs independently. More... | |
id | get_id () const noexcept |
Returns the identifier of the thread associated with this thread object. More... | |
native_handle_type | native_handle () const |
Get a handle for the wrapped Eina_Thread . More... | |
Static Public Member Functions | |
static unsigned | hardware_concurrency () noexcept |
Get the number of hardware concurrent threads. More... | |
Provides an OOP interface to the Eina_Thread
and automatic resource allocation and deallocation using the RAII programming idiom.
This class implements threads in a way that strongly resembles the STL std::thread
.
typedef thread_id efl::eina::thread::id |
Type for the thread identifier.
Type for the native Eina_Thread handle.
|
inlineexplicit |
Creates a thread of execution.
f | Pointer to function or callable object to execute in the new thread. The return value (if any) is ignored. |
args | Arguments to pass to the f . |
This constructor creates a thread object that represents a thread of execution. The new thread of execution calls f
passing args
as arguments (all arguments are copied/moved to thread-accessible storage).
Any exceptions thrown during evaluation and copying/moving of the arguments are thrown in the current thread, not the new thread.
References eina_condition_new(), eina_lock_new(), eina_thread_create(), and efl::eina::get_error_code().
|
inline |
Move constructor.
Transfer the thread of execution to the new object.
other | Another thread object to construct this thread object with. |
This constructor creates a thread object that acquires the thread of execution represented by other
. This operation does not affect the execution of the moved thread, it simply transfers its handler.
other
no longer represents a thread of execution. Transfer the thread of execution.
other | Another thread object to assign to this thread object. |
other
no longer represents a thread of execution.
|
inlinenoexcept |
Exchanges the underlying handles of two thread objects.
other | Another thread object. |
References efl::eina::swap().
Referenced by efl::eina::swap().
|
inlinenoexcept |
Check if the thread object identifies an active thread of execution.
true
if the thread object identifies an active thread of execution, false
otherwise.This member function checks if the thread object identifies an active thread of execution. A default constructed thread is not joinable, as well as a thread that its members join or detach has been called.
A thread that has finished executing code, but has not yet been joined is still considered an active thread of execution and is therefore joinable.
|
inline |
Wait for the thread to finish its execution.
This member function blocks the calling thread until the thread identified by this object finishes its execution.
References eina_thread_join(), and joinable().
|
inline |
Detaches the thread from its handle, making it runs independently.
This member function separates the thread of execution from the thread object, allowing execution to continue independently.
References joinable().
|
inlinenoexcept |
Returns the identifier of the thread associated with this thread object.
thread::id
identifying the thread associated with this thread object.
|
inline |
Get a handle for the wrapped Eina_Thread
.
Eina_Thread
.This member function returns the native Eina_Thread
handle that is wrapped inside this object.
|
inlinestaticnoexcept |
Get the number of hardware concurrent threads.
0
if the value is not well defined or not computable.This static member function returns the number of hardware concurrent threads.
References eina_cpu_count().