TDME2 1.9.121
Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes | List of all members
Thread Class Referenceabstract

Base class for threads. More...

#include <tdme/os/threading/Thread.h>

Inheritance diagram for Thread:
Inheritance graph
Collaboration diagram for Thread:
Collaboration graph

Public Member Functions

 Thread (const string &name, size_t stackSize=2 *1024 *1024)
 Public constructor. More...
 
virtual ~Thread ()
 Public destructor. More...
 
void join ()
 Blocks caller thread until this thread has been terminated. More...
 
void start ()
 Starts this objects thread. More...
 
virtual void run ()=0
 Abstract run() method, should be implemented by subclassed class, will be called after spawn by start() More...
 
void stop ()
 Requests that this thread should be stopped. More...
 
bool isStopRequested ()
 Returns if stop has been requested. More...
 

Static Public Member Functions

static int getHardwareThreadCount ()
 
static void sleep (const uint64_t milliseconds)
 sleeps current thread for given time in milliseconds More...
 

Static Private Member Functions

static void * pThreadRun (void *thread)
 

Private Attributes

pthread_t pThread
 
string name
 
bool pThreadCreated
 
volatile bool stopRequested
 
size_t stackSize
 

Detailed Description

Base class for threads.

Author
Andreas Drewke

Definition at line 26 of file Thread.h.

Constructor & Destructor Documentation

◆ Thread()

Thread ( const string &  name,
size_t  stackSize = 2 * 1024 * 1024 
)

Public constructor.

Parameters
namename
stackSizestack size, defaults to 2MB

Definition at line 24 of file Thread.cpp.

◆ ~Thread()

~Thread ( )
virtual

Public destructor.

Definition at line 27 of file Thread.cpp.

Member Function Documentation

◆ getHardwareThreadCount()

int getHardwareThreadCount ( )
static
Returns
hardware thread count

Definition at line 30 of file Thread.cpp.

◆ isStopRequested()

bool isStopRequested ( )

Returns if stop has been requested.

Returns
bool

Definition at line 98 of file Thread.cpp.

◆ join()

void join ( )

Blocks caller thread until this thread has been terminated.

Definition at line 55 of file Thread.cpp.

◆ pThreadRun()

void * pThreadRun ( void *  thread)
staticprivate

Definition at line 88 of file Thread.cpp.

◆ run()

virtual void run ( )
pure virtual

Abstract run() method, should be implemented by subclassed class, will be called after spawn by start()

Implemented in Engine::EngineThread, UDPClient, ServerWorkerThread, UDPServer, UDPServerIOThread, EditorScreenController::FileOpenThread, EditorScreenController::ScanFilesThread, and Console::LogWriterThread.

◆ sleep()

void sleep ( const uint64_t  milliseconds)
static

sleeps current thread for given time in milliseconds

Parameters
millisecondsuint64_t milliseconds to wait

Definition at line 34 of file Thread.cpp.

◆ start()

void start ( )

Starts this objects thread.

Definition at line 65 of file Thread.cpp.

◆ stop()

void stop ( )

Requests that this thread should be stopped.

Definition at line 94 of file Thread.cpp.

Member Data Documentation

◆ name

string name
private

Definition at line 83 of file Thread.h.

◆ pThread

pthread_t pThread
private

Definition at line 81 of file Thread.h.

◆ pThreadCreated

bool pThreadCreated
private

Definition at line 84 of file Thread.h.

◆ stackSize

size_t stackSize
private

Definition at line 86 of file Thread.h.

◆ stopRequested

volatile bool stopRequested
private

Definition at line 85 of file Thread.h.


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