NDEVR
API Documentation

The default thread class for executing concurrent sequences in the NDEVR API. More...

Inheritance diagram for Thread:
[legend]

Public Member Functions

 Thread ()
 Constructs a Thread with a default name.
 Thread (const StringView &name)
 Constructs a Thread with the specified name.
virtual ~Thread ()
 Destroys the Thread and cleans up resources.
void detach ()
 Detaches the thread, allowing it to run independently.
void forceStop ()
 Forces the running flag to false without waiting for the thread to finish.
bool isPrimaryThread () const
 Checks whether this thread is the primary thread.
bool isRunning () const
 Checks whether the thread is currently running.
void join ()
 Blocks the calling thread until this thread finishes execution.
virtual void requestStopThread ()
 Requests the thread to stop without blocking.
void setIsPrimaryThread (bool is_primary_thread)
 Sets whether this thread should be treated as the primary thread.
void setThreadName (const StringView &name)
 Sets the name of this thread.
virtual bool shouldExitThread () const
 Checks whether the thread has been requested to exit.
void start ()
 Starts the thread execution.
virtual void stopThread ()
 Stops the thread and waits for it to finish.
const StringthreadName () const
 Gets the name assigned to this thread.

Static Public Member Functions

static ThreadCurrentThread ()
 Gets a reference to the Thread object for the calling thread.
static String CurrentThreadName ()
 Gets the name of the current thread.
static void ServiceVirtualThreads ()
 Services any virtual threads that require periodic execution.
static void SetCurrentThreadName (const StringView &name)
 Sets the name of the current thread.
static void StopAllThreads ()
 Stops all tracked threads.

Protected Member Functions

virtual void run ()
 The main execution body of the thread.
const std::thread & self ()
 Gets a const reference to the underlying std::thread.

Protected Attributes

volatile bool m_is_running = false
 Whether the thread is currently running.
volatile bool m_is_single_run = true
 Whether the thread should execute only once before stopping.

Detailed Description

The default thread class for executing concurrent sequences in the NDEVR API.


See also
BasicThread, ThreadQueue, RWLock

Definition at line 112 of file Thread.h.

Constructor & Destructor Documentation

◆ Thread()

Thread::Thread ( const StringView & name)

Constructs a Thread with the specified name.

Parameters
[in]nameThe name to assign to this thread.

References Thread().

Member Function Documentation

◆ CurrentThread()

Thread & Thread::CurrentThread ( )
static

Gets a reference to the Thread object for the calling thread.

Returns
A reference to the current Thread.

References Thread().

◆ CurrentThreadName()

String Thread::CurrentThreadName ( )
static

Gets the name of the current thread.

Returns
The name of the calling thread.

◆ isPrimaryThread()

bool Thread::isPrimaryThread ( ) const

Checks whether this thread is the primary thread.

Returns
True if this is the primary thread, false otherwise.

◆ isRunning()

bool Thread::isRunning ( ) const

Checks whether the thread is currently running.

Returns
True if the thread is running, false otherwise.

◆ run()

virtual void Thread::run ( )
inlineprotectedvirtual

The main execution body of the thread.

Override this to define thread behavior.

Reimplemented in BasicThread, CachedFactoryIOThread, LocalApplicationLauncherThread, and ThreadQueue.

Definition at line 216 of file Thread.h.

Referenced by NDEVRMouseManager::clearEvents().

◆ self()

const std::thread & Thread::self ( )
protected

Gets a const reference to the underlying std::thread.

Returns
A const reference to the std::thread object.

◆ SetCurrentThreadName()

void Thread::SetCurrentThreadName ( const StringView & name)
static

Sets the name of the current thread.

Parameters
[in]nameThe name to assign to the current thread.

◆ setIsPrimaryThread()

void Thread::setIsPrimaryThread ( bool is_primary_thread)

Sets whether this thread should be treated as the primary thread.

Parameters
[in]is_primary_threadTrue to designate this thread as primary.

◆ setThreadName()

void Thread::setThreadName ( const StringView & name)

Sets the name of this thread.

Parameters
[in]nameThe name to assign.

◆ shouldExitThread()

virtual bool Thread::shouldExitThread ( ) const
virtual

Checks whether the thread has been requested to exit.

Returns
True if the thread should exit, false otherwise.

◆ threadName()

const String & Thread::threadName ( ) const
inline

Gets the name assigned to this thread.

Returns
A const reference to the thread name.

Definition at line 178 of file Thread.h.


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