The class thread represents a single thread of execution.
More...
#include <Thread.h>
|
virtual | ~IThread () |
| Joins and destroys the object. More...
|
|
virtual bool | is_running () const =0 |
| Checks if the thread is still running.
|
|
virtual void | join ()=0 |
| Cancels and waits for thread termination. More...
|
|
virtual void | yield () const =0 |
| if supported by the platform implementation, passes the execution of the thread to another thread. More...
|
|
virtual void * | handle ()=0 |
| Returns the platform dependent handle associated to this object.
|
|
|
static Thread | create (Task task) |
| Creates one new thread to execute one single task. More...
|
|
static Thread | self () |
| Returns an handle to control the current thread.
|
|
The class thread represents a single thread of execution.
Threads allow multiple pieces of code to run asynchronously and simultaneously.
class MyTask:
{
void execute( ) { ... }
}
int main( )
{
Task task = std::make_shared< MyTask >( );
...
my_thread->join( );
}
virtual IThread::~IThread |
( |
| ) |
|
|
inlinevirtual |
Joins and destroys the object.
Before destroying the object calls the method join to ensure the handled thread is terminated.
- Precondition
- The object cannot be destroyed by its own thread.
static Thread IThread::create |
( |
Task |
task | ) |
|
|
static |
Creates one new thread to execute one single task.
- Parameters
-
task | Shared pinter to a ITask to be executed by the thread. The created thread also takes ownership of the task during its execution. |
- Returns
- A shared pointer to an object to check and control the created thread. The created thread is also taking ownership to the returned object.
virtual void IThread::join |
( |
| ) |
|
|
pure virtual |
Cancels and waits for thread termination.
- Precondition
- This method cannot be from the whole thread.
virtual void IThread::yield |
( |
| ) |
const |
|
pure virtual |
if supported by the platform implementation, passes the execution of the thread to another thread.
- Precondition
- This method can be called only from the whole thread.
The documentation for this class was generated from the following file: