Thread. More...
#include <rthread.h>
Public Member Functions | |
RThread (size_t id=0, const RString name=RString::Null) | |
size_t | GetId (void) const |
RString | GetName (void) const |
void | Start (void) |
void | Wait (void) |
virtual | ~RThread (void) |
Private Member Functions | |
virtual void | Run (void)=0 |
Static Private Member Functions | |
static void * | ThreadFunc (void *) |
Private Attributes | |
pthread_t | Thread |
RString | Name |
size_t | Id |
Detailed Description
Thread.
The RThread class provides a representation for a thread. The method Run must be overloaded and contains the code that has to be runned by the thread.
An identifier and a name can be assigned to a thread. There have no management role. In particular, multiple threads may have the same identifier (a default null value is specified). The identifier may serve to ensure that each thread running the same portion of code uses it own data:
Constructor & Destructor Documentation
RThread | ( | size_t | id = 0 , |
const RString | name = RString::Null |
||
) |
Construct a thread.
- Parameters
-
id Identifier of the thread. name Name of the thread.
|
virtual |
Destroy the thread. In fact, destroying the RThread class does not terminate the execution of the thread.
Member Function Documentation
|
staticprivate |
Internal method used by the PTHREAD library.
size_t GetId | ( | void | ) | const |
Get the identifier of the thread.
- Returns
- a size_t
void Start | ( | void | ) |
Start the execution of the thread.
void Wait | ( | void | ) |
Wait that the thread is finished. In practice, the calling thread is blocked until the thread finishes its execution.
|
privatepure virtual |
Method containing the code to be executed by the thread. It must be overloaded by child classes.
Field Documentation
|
private |
The thread structure.
|
private |
Name of the thread.
|
private |
Thread identifier.