RR Thread Pool
 All Classes Functions Typedefs Groups Pages
Public Member Functions | Static Public Member Functions | List of all members
IThread Class Referenceabstract

The class thread represents a single thread of execution. More...

#include <Thread.h>

Public Member Functions

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 Public Member Functions

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.
 

Detailed Description

The class thread represents a single thread of execution.

Threads allow multiple pieces of code to run asynchronously and simultaneously.

class MyTask:
public ITask
{
void execute( ) { ... }
}
int main( )
{
Task task = std::make_shared< MyTask >( );
Thread my_thread = IThread::create( task );
...
my_thread->join( );
}

Constructor & Destructor Documentation

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
  1. The object cannot be destroyed by its own thread.

Member Function Documentation

static Thread IThread::create ( Task  task)
static

Creates one new thread to execute one single task.

Parameters
taskShared 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
  1. 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
  1. This method can be called only from the whole thread.

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