34#include <NDEVR/String.h>
35#include <NDEVR/Dictionary.h>
36#if NDEVR_SUPPORTS_THREADING
104 static uint04 s_primary_thread_id;
106#if NDEVR_SUPPORTS_THREADING
221 void startInThread();
227 static uint08 GetThreadCount() {
return s_thread_count; }
232 static void _setThreadName(
const StringView& name);
235 std::thread* m_tid =
nullptr;
236 uint04 m_thread_id = Constant<uint04>::Invalid;
241 volatile static uint04 s_thread_count;
A hash-based key-value store, useful for quick associative lookups.
A light-weight base class for Log that allows processes to update, without the need for additional in...
A light-weight wrapper that will be a no-op if there is not a valid log reference,...
The core String View class for the NDEVR API.
The core String class for the NDEVR API.
Forward declaration of LogPtr for log access.
static String CurrentThreadName()
Gets the name of the current thread.
static uint04 PrimaryThreadID()
Gets the unique identifier of the primary thread.
static void SetCurrentThreadName(const StringView &name)
Sets the name of the current thread for debugging and identification.
static void RequestSleep(const TimeSpan &interval)
Puts the current thread to sleep for a specified duration.
static bool IsPrimaryThread()
Checks whether the calling thread is the primary (main) thread.
static void SetPrimaryThreadID(uint04 primary_thread)
Sets the thread ID that should be considered the primary thread.
static void RequestNoSleep(bool request_no_sleep, const LogPtr &log)
Requests that the system prevent or allow the device to sleep.
static void RequestConcurrentExecution(const StringView &name, const std::function< void()> &function)
Requests that a function be executed concurrently on a separate thread.
static uint04 CurrentThreadID()
Gets the unique identifier of the current thread.
void forceStop()
Forces the running flag to false without waiting for the thread to finish.
volatile bool m_is_running
Whether the thread is currently running.
bool isRunning() const
Checks whether the thread is currently running.
virtual ~Thread()
Destroys the Thread and cleans up resources.
const std::thread & self()
Gets a const reference to the underlying std::thread.
virtual void requestStopThread()
Requests the thread to stop without blocking.
static String CurrentThreadName()
Gets the name of the current thread.
static void StopAllThreads()
Stops all tracked threads.
void join()
Blocks the calling thread until this thread finishes execution.
static void SetCurrentThreadName(const StringView &name)
Sets the name of the current thread.
virtual void stopThread()
Stops the thread and waits for it to finish.
Thread()
Constructs a Thread with a default name.
void setThreadName(const StringView &name)
Sets the name of this thread.
const String & threadName() const
Gets the name assigned to this thread.
volatile bool m_is_single_run
Whether the thread should execute only once before stopping.
void setIsPrimaryThread(bool is_primary_thread)
Sets whether this thread should be treated as the primary thread.
Thread(const StringView &name)
Constructs a Thread with the specified name.
static Thread & CurrentThread()
Gets a reference to the Thread object for the calling thread.
static void ServiceVirtualThreads()
Services any virtual threads that require periodic execution.
void detach()
Detaches the thread, allowing it to run independently.
virtual bool shouldExitThread() const
Checks whether the thread has been requested to exit.
bool isPrimaryThread() const
Checks whether this thread is the primary thread.
void start()
Starts the thread execution.
virtual void run()
The main execution body of the thread.
Stores a time span, or difference between two times, with an optional start time.
The primary namespace for the NDEVR SDK.
uint64_t uint08
-Defines an alias representing an 8 byte, unsigned integer
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...