An abstract class for defining classes that operate as a thread. More...
#include <thread.h>
Public Member Functions | |
void | setPriority (void) |
Set thread priority without disrupting scheduling if possible. | |
virtual void | run (void)=0 |
Abstract interface for thread context run method. | |
virtual | ~Thread () |
Destroy thread object, thread-specific data, and execution context. | |
virtual void | exit (void) |
Exit the thread context. | |
Static Public Member Functions | |
static void | yield (void) |
Yield execution context of the current thread. | |
static void | sleep (timeout_t timeout) |
Sleep current thread for a specified time period. | |
static void | init (void) |
Used to initialize threading library. | |
static void | policy (int polid) |
Used to specify scheduling policy for threads above priority "0". | |
static void | concurrency (int level) |
Set concurrency level of process. | |
static bool | equal (pthread_t thread1, pthread_t thread2) |
Determine if two thread identifiers refer to the same thread. | |
static pthread_t | self (void) |
Get current thread id. | |
Protected Member Functions | |
Thread (size_t stack=0) | |
Create a thread object that will have a preset stack size. | |
Protected Attributes | |
pthread_t | tid |
size_t | stack |
int | priority |
An abstract class for defining classes that operate as a thread.
A derived thread class has a run method that is invoked with the newly created thread context, and can use the derived object to store all member data that needs to be associated with that context. This means the derived object can safely hold thread-specific data that is managed with the life of the object, rather than having to use the clumsy thread-specific data management and access functions found in thread support libraries.
Definition at line 1437 of file thread.h.
ucc::Thread::Thread | ( | size_t | stack = 0 |
) | [protected] |
static void ucc::Thread::concurrency | ( | int | level | ) | [static] |
Set concurrency level of process.
This is essentially a portable wrapper for pthread_setconcurrency.
static bool ucc::Thread::equal | ( | pthread_t | thread1, | |
pthread_t | thread2 | |||
) | [static] |
Determine if two thread identifiers refer to the same thread.
thread1 | to test. | |
thread2 | to test. |
virtual void ucc::Thread::exit | ( | void | ) | [virtual] |
Exit the thread context.
This function should NO LONGER be called directly to exit a running thread. Instead this method will only be used to modify the behavior of the thread context at thread exit, including detached threads which by default delete themselves. This documented usage was changed to support Mozilla NSPR exit behavior in case we support NSPR as an alternate thread runtime in the future.
Reimplemented in ucc::DetachedThread.
static void ucc::Thread::init | ( | void | ) | [static] |
Used to initialize threading library.
May be needed for some platforms.
static void ucc::Thread::policy | ( | int | polid | ) | [static] |
Used to specify scheduling policy for threads above priority "0".
Normally we apply static realtime policy SCHED_FIFO (default) or SCHED_RR. However, we could apply SCHED_OTHER, etc.
static pthread_t ucc::Thread::self | ( | void | ) | [inline, static] |
void ucc::Thread::setPriority | ( | void | ) |
Set thread priority without disrupting scheduling if possible.
Based on scheduling policy. It is recommended that the process is set for realtime scheduling, and this method is actually for internal use.
static void ucc::Thread::sleep | ( | timeout_t | timeout | ) | [static] |
Sleep current thread for a specified time period.
timeout | to sleep for in milliseconds. |
static void ucc::Thread::yield | ( | void | ) | [static] |
Yield execution context of the current thread.
This is a static and may be used anywhere.