PixelLightAPI  .
Public Types | Public Member Functions
PLCore::Thread Class Reference

Thread class. More...

#include <Thread.h>

Inheritance diagram for PLCore::Thread:
Inheritance graph
[legend]

List of all members.

Public Types

enum  EPriorityClass {
  IdlePriorityClass, BelowNormalPriorityClass, NormalPriorityClass, AboveNormalPriorityClass,
  HighPriorityClass, RealtimePriorityClass
}
 Thread priority class. More...
enum  EPriority {
  IdlePriority, LowestPriority, BelowNormalPriority, NormalPriority,
  AboveNormalPriority, HighestPriority, TimeCriticalPriority
}
 Thread priority within the priority class it is in. More...

Public Member Functions

PLCORE_API Thread ()
 Constructor.
PLCORE_API Thread (ThreadFunction *pThreadFunction)
 Constructor.
PLCORE_API Thread (THREADFUNCTION pThreadFunction, void *pData)
 Constructor.
PLCORE_API Thread (handle nThreadID)
 Constructor.
virtual PLCORE_API ~Thread ()
 Destructor.
String GetName () const
 Returns the name of the thread.
void SetName (const String &sName)
 Sets the name of the thread.
handle GetID () const
 Returns the unique system ID of the thread.
bool IsActive () const
 Returns whether the thread is active.
bool Start ()
 Starts the execution of the thread.
bool Terminate ()
 Stops the execution of the thread.
bool Join ()
 Waits until the thread has been stopped.
bool Join (uint64 nTimeout)
 Waits until the thread has been stopped.
EPriorityClass GetPriorityClass () const
 Returns the priority class the thread is in.
bool SetPriorityClass (EPriorityClass nPriorityClass=NormalPriorityClass)
 Sets the priority class the thread is in.
EPriority GetPriority () const
 Returns the thread priority within the priority class it is in.
bool SetPriority (EPriority nPriority=NormalPriority)
 Sets the thread priority within the priority class it is in.
virtual PLCORE_API int Run () override
 Function to be executed.

Detailed Description

Thread class.

Note:
  • Implementation of the bridge design pattern, this class is the abstraction

Member Enumeration Documentation

Thread priority class.

Enumerator:
IdlePriorityClass 

Idle priority class

BelowNormalPriorityClass 

Below normal priority class

NormalPriorityClass 

Normal priority class (default)

AboveNormalPriorityClass 

Above normal priority class

HighPriorityClass 

High priority class

RealtimePriorityClass 

Realtime priority class (ONLY use this if you REALLY need it!)

Thread priority within the priority class it is in.

Enumerator:
IdlePriority 

Idle priority

LowestPriority 

Lowest priority

BelowNormalPriority 

Below normal priority

NormalPriority 

Normal priority (default)

AboveNormalPriority 

Above normal priority

HighestPriority 

Highest priority

TimeCriticalPriority 

Time critical priority


Constructor & Destructor Documentation

PLCORE_API PLCore::Thread::Thread ( )
PLCORE_API PLCore::Thread::Thread ( ThreadFunction pThreadFunction)

Constructor.

Parameters:
[in]pThreadFunctionPointer to the thread function, can be a null pointer
PLCORE_API PLCore::Thread::Thread ( THREADFUNCTION  pThreadFunction,
void *  pData 
)

Constructor.

Parameters:
[in]pThreadFunctionPointer to a static thread function, can be a null pointer
[in]pDataData to be passed to the thread function, can be a null pointer
PLCORE_API PLCore::Thread::Thread ( handle  nThreadID)

Constructor.

Parameters:
[in]nThreadIDA system specific thread ID, NULL_HANDLE for current thread
virtual PLCORE_API PLCore::Thread::~Thread ( ) [virtual]

Destructor.


Member Function Documentation

String PLCore::Thread::GetName ( ) const [inline]

Returns the name of the thread.

Returns:
Thread name
Remarks:
The thread name is not used internally, it's for user usage only and especially for debugging purposes quite useful. It's recommended to give threads unique names. By default, no thread name is set.
void PLCore::Thread::SetName ( const String sName) [inline]

Sets the name of the thread.

Parameters:
[in]sNameThread name
See also:
handle PLCore::Thread::GetID ( ) const [inline]

Returns the unique system ID of the thread.

Returns:
Thread ID
bool PLCore::Thread::IsActive ( ) const [inline]

Returns whether the thread is active.

Returns:
'true' if the thread is active, else 'false'
bool PLCore::Thread::Start ( ) [inline]

Starts the execution of the thread.

Returns:
'true' if the thread could be started
bool PLCore::Thread::Terminate ( ) [inline]

Stops the execution of the thread.

Returns:
'true' if the thread could be stopped
Remarks:
Terminates the thread ungracefully (does not allow proper thread clean up!). Instead of using this function you should signal the thread and wait until it has quit by itself. The internal platform implementation may or may not accept this violent act. For example, Androids Bionic doesn't support it and a call of this method will have no effect at all.
bool PLCore::Thread::Join ( ) [inline]

Waits until the thread has been stopped.

Returns:
'true' if the thread has been stopped
Note:
  • It's recommended to use the join version with a timeout instead of this function to ensure that the thread is stopped within a defined time (no deadlock's)
bool PLCore::Thread::Join ( uint64  nTimeout) [inline]

Waits until the thread has been stopped.

Parameters:
[in]nTimeoutTime in milliseconds to wait
Returns:
'true' if the thread has been stopped

Returns the priority class the thread is in.

Returns:
The priority class the thread is in
Remarks:
The thread priority settings are only 'hints' for the OS how to deal with the thread. They are no 'facts' and may differ from OS to OS.

Sets the priority class the thread is in.

Parameters:
[in]nPriorityClassNew priority class the thread is in
Returns:
'true' if all went fine, else 'false'
See also:

Returns the thread priority within the priority class it is in.

Returns:
The thread priority within the priority class it is in
See also:
bool PLCore::Thread::SetPriority ( EPriority  nPriority = NormalPriority) [inline]

Sets the thread priority within the priority class it is in.

Parameters:
[in]nPriorityNew thread priority within the priority class it is in
Returns:
'true' if all went fine, else 'false'
See also:
virtual PLCORE_API int PLCore::Thread::Run ( ) [override, virtual]

Function to be executed.

Returns:
Return value after execution

Implements PLCore::ThreadFunction.


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:28
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported