![]() |
Dataflow Runtime API
3.0.3.0
|
A thread is a thread of execution in a program. More...
#include <Imt.Base.OS.WinEC7/Thread.h>
Public Types | |
enum | WaitResult { WaitResult_Done = 0 , WaitResult_Timeout = -1 , WaitResult_Error = -2 } |
Public Member Functions | |
Thread (const std::wstring &id, RunnableIfc &runnable) | |
Constructor. More... | |
virtual | ~Thread (void) |
Destructor. More... | |
int32_t | getPriority (void) const |
Returns the priority of this thread. More... | |
void | setPriority (const int32_t priority) |
Sets the priority to this thread. More... | |
void | start (void) |
Starts the given thread. More... | |
bool | isRunning (void) const |
Returns true if the thread is running. More... | |
void | stop (void) |
Stops the given thread in a friendly (synchronous) way. More... | |
bool | isStopRequested (void) const |
Returns true if the thread should stop. More... | |
void | terminate (void) |
Stops the given thread in an unfriendly (asynchronous) way. More... | |
void | suspend (void) |
Increments the suspend count of the target thread by one. More... | |
void | resume (void) |
Decrements the suspend count by one. More... | |
const std::wstring & | getId (void) const |
Get identification. More... | |
RunnableIfc & | getRunnable (void) |
Getter for the Runnable. More... | |
Static Public Member Functions | |
static void | stop (Thread &thread, const TimePeriod &waitTimeout) |
Stops the given thread in a friendly (synchronous) way. More... | |
static void | sleep (const TimePeriod &sleepTime) |
Causes the current executing thread to sleep for the specified TimePeriod. More... | |
static int32_t | waitForEvent (OSEvent *const pEvent, const TimePeriod &timeout) |
Causes the current executing thread to block until at least the single event or the timeout occurs. More... | |
static int32_t | waitForEvents (OSEvent **const ppEvents, const uint32_t eventCount, const TimePeriod &timeout) |
Causes the current executing thread to block until at least one of the given events get signaled or the timeout occurs. More... | |
static bool | join (Thread &thread, const TimePeriod &waitTimeout) |
Waits for this thread to die. More... | |
A thread is a thread of execution in a program.
Every thread has a priority. Threads with higher priority are executed in preference to threads with lower priority.
Declare a class that implements the Runnable interface. That class then implements the run method. An instance of the class can then be allocated, passed as an argument when creating Thread, and started.
|
explicit |
Constructor.
id | Identifier of the thread. |
runnable | Runnable to perform by this thread. |
|
virtual |
Destructor.
const std::wstring& imt::base::os::winec7::Thread::getId | ( | void | ) | const |
Get identification.
int32_t imt::base::os::winec7::Thread::getPriority | ( | void | ) | const |
Returns the priority of this thread.
RunnableIfc& imt::base::os::winec7::Thread::getRunnable | ( | void | ) |
Getter for the Runnable.
bool imt::base::os::winec7::Thread::isRunning | ( | void | ) | const |
Returns true if the thread is running.
bool imt::base::os::winec7::Thread::isStopRequested | ( | void | ) | const |
Returns true if the thread should stop.
|
static |
Waits for this thread to die.
thread | Thread to wait for exit |
waitTimeout | Wait timeout for the exit |
void imt::base::os::winec7::Thread::resume | ( | void | ) |
Decrements the suspend count by one.
If the suspend count is 0, the target thread resumes execution.
void imt::base::os::winec7::Thread::setPriority | ( | const int32_t | priority | ) |
Sets the priority to this thread.
|
static |
Causes the current executing thread to sleep for the specified TimePeriod.
sleepTime | Sleep time in milliseconds. |
void imt::base::os::winec7::Thread::start | ( | void | ) |
Starts the given thread.
|
static |
Stops the given thread in a friendly (synchronous) way.
thread | The thread to stop |
waitTimeout | The wait time that is waited in join |
void imt::base::os::winec7::Thread::stop | ( | void | ) |
Stops the given thread in a friendly (synchronous) way.
You have to call Thread::join to wait for the exit of the given thread
void imt::base::os::winec7::Thread::suspend | ( | void | ) |
Increments the suspend count of the target thread by one.
If the suspend count gets > 0, the target thread ceases execution.
void imt::base::os::winec7::Thread::terminate | ( | void | ) |
|
static |
Causes the current executing thread to block until at least the single event or the timeout occurs.
pEvent | Pointer onto the event. |
timeout | Timeout time in system ticks. |
|
static |
Causes the current executing thread to block until at least one of the given events get signaled or the timeout occurs.
The maximum number of events is limited to MAX_NUMBER_OF_EVENTS
ppEvents | Pointer onto an array of events. |
eventCount | Number of events in the given event array. |
timeout | Timeout time in system ticks. |