Dataflow Runtime API  3.0.3.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
imt::base::os::winec7::Thread Class Reference

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...
 
RunnableIfcgetRunnable (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...
 

Detailed Description

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.

Member Enumeration Documentation

◆ WaitResult

Enumerator
WaitResult_Done 
WaitResult_Timeout 
WaitResult_Error 

Constructor & Destructor Documentation

◆ Thread()

imt::base::os::winec7::Thread::Thread ( const std::wstring &  id,
RunnableIfc runnable 
)
explicit

Constructor.

Parameters
idIdentifier of the thread.
runnableRunnable to perform by this thread.

◆ ~Thread()

virtual imt::base::os::winec7::Thread::~Thread ( void  )
virtual

Destructor.

Member Function Documentation

◆ getId()

const std::wstring& imt::base::os::winec7::Thread::getId ( void  ) const

Get identification.

Returns
Identifier of this thread.

◆ getPriority()

int32_t imt::base::os::winec7::Thread::getPriority ( void  ) const

Returns the priority of this thread.

◆ getRunnable()

RunnableIfc& imt::base::os::winec7::Thread::getRunnable ( void  )

Getter for the Runnable.

Returns
Runnable to perform by this thread.

◆ isRunning()

bool imt::base::os::winec7::Thread::isRunning ( void  ) const

Returns true if the thread is running.

Returns
True if the thread is running

◆ isStopRequested()

bool imt::base::os::winec7::Thread::isStopRequested ( void  ) const

Returns true if the thread should stop.

Returns
True if the thread should stop

◆ join()

static bool imt::base::os::winec7::Thread::join ( Thread thread,
const TimePeriod waitTimeout 
)
static

Waits for this thread to die.

Parameters
threadThread to wait for exit
waitTimeoutWait timeout for the exit
Returns
true if the thread exited

◆ resume()

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.

◆ setPriority()

void imt::base::os::winec7::Thread::setPriority ( const int32_t  priority)

Sets the priority to this thread.

◆ sleep()

static void imt::base::os::winec7::Thread::sleep ( const TimePeriod sleepTime)
static

Causes the current executing thread to sleep for the specified TimePeriod.

Parameters
sleepTimeSleep time in milliseconds.

◆ start()

void imt::base::os::winec7::Thread::start ( void  )

Starts the given thread.

◆ stop() [1/2]

static void imt::base::os::winec7::Thread::stop ( Thread thread,
const TimePeriod waitTimeout 
)
static

Stops the given thread in a friendly (synchronous) way.

Parameters
threadThe thread to stop
waitTimeoutThe wait time that is waited in join

◆ stop() [2/2]

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

◆ suspend()

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.

◆ terminate()

void imt::base::os::winec7::Thread::terminate ( void  )

Stops the given thread in an unfriendly (asynchronous) way.

Use this method only if stop() and join() have failed!

◆ waitForEvent()

static int32_t imt::base::os::winec7::Thread::waitForEvent ( OSEvent *const  pEvent,
const TimePeriod timeout 
)
static

Causes the current executing thread to block until at least the single event or the timeout occurs.

Parameters
pEventPointer onto the event.
timeoutTimeout time in system ticks.
Returns
-1 if timeout, -2 if error or index of signaled event.

◆ waitForEvents()

static int32_t imt::base::os::winec7::Thread::waitForEvents ( OSEvent **const  ppEvents,
const uint32_t  eventCount,
const TimePeriod timeout 
)
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

Parameters
ppEventsPointer onto an array of events.
eventCountNumber of events in the given event array.
timeoutTimeout time in system ticks.
Returns
-1 if timeout, -2 if error or index of signaled event.

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