143 bool Start() noexcept;
161 bool Stop() noexcept;
183 virtual uint32_t
Step() noexcept = 0;
294 int core_id) noexcept;
Generic RTOS abstraction — public header.
C-facing helper functions for delays, cycle counters, and creation of RTOS handles (queues,...
SignalSemaphore class definition.
Abstract class to assist in designing thread-based execution sequences.
Definition BaseThread.h:32
virtual bool Initialize() noexcept=0
Function to initialize thread. Generally, the initialize function should return false rather than cau...
bool EnsureInitialized() noexcept
Initialize the thread.
Definition BaseThread.h:88
virtual uint32_t Step() noexcept=0
Steps the thread through a single execution cycle .
bool IsThreadInStepDelay() const noexcept
Definition BaseThread.h:127
bool IsSuspended() noexcept
Check the status of the underlying thread OS task.
Definition BaseThread.cpp:155
std::atomic< bool > setupComplete
Definition BaseThread.h:360
bool osThreadCreated
Definition BaseThread.h:349
bool initialized
Definition BaseThread.h:346
BaseThread(const BaseThread &)=delete
The Copy constructor is deleted to avoid copying instances.
virtual bool Setup() noexcept=0
Setup the thread.
virtual bool StartAction() noexcept
Start Action that can be run to see if Start() qualifies to start thread.
Definition BaseThread.cpp:192
static constexpr char baseThreadStartSemaphoreBaseName[]
Definition BaseThread.h:351
const char * osThreadName
Definition BaseThread.h:348
bool CreateBaseThread(uint8_t *stack, OS_Ulong stackSizeBytes, OS_Uint priority, OS_Uint preempt_threshold, OS_Ulong timeSliceAllowed, OS_Uint auto_start) noexcept
Function to Create TX thread.
Definition BaseThread.cpp:81
std::atomic< bool > stopThreadRequested
Definition BaseThread.h:362
void WaitForStart() noexcept
Starts the thread.
Definition BaseThread.cpp:259
virtual bool ResetVariables() noexcept=0
Resets all member variables to their initial states.
bool IsCleanupComplete() const noexcept
Definition BaseThread.h:126
std::atomic< bool > cleanupComplete
Definition BaseThread.h:361
uint32_t waitBeforeStep
Definition BaseThread.h:355
bool IsThreadRunning() const noexcept
Definition BaseThread.h:120
bool ChangePriority(uint32_t newPriority) noexcept
Change the running priority of the thread.
Definition BaseThread.cpp:331
uint32_t GetStackHighWaterMark() const noexcept
Get the minimum remaining stack of the task.
Definition BaseThread.cpp:307
void MarkThreadStepInDelay() noexcept
Indicate a request to stop the thread.
Definition BaseThread.h:339
void ClearThreadRunning() noexcept
Mark the thread as not running.
Definition BaseThread.h:324
bool Resume() noexcept
Resume the underlying thread OS task.
Definition BaseThread.cpp:140
void MarkThreadStopRequested() noexcept
Indicate a request to stop the thread.
Definition BaseThread.h:329
bool StopThreadAndWaitToVerify(uint32_t stopTimeoutMsec)
[BLOCKING] Signals a BaseThread to stop and waits to make sure it's started within the given timeout.
Definition BaseThread.cpp:287
virtual bool Cleanup() noexcept=0
Cleanup code that exists once the thread step sequence is stopped. The cleanup function should genera...
bool IsSetupComplete() const noexcept
Definition BaseThread.h:119
bool IsInitialized() const noexcept
This function checks if the class is initialized;.
Definition BaseThread.h:75
std::atomic< bool > threadRunning
Definition BaseThread.h:358
bool IsThreadStopRequested() noexcept
Definition BaseThread.h:118
OS_Thread osThread
Definition BaseThread.h:347
void MarkThreadRunning() noexcept
Mark the thread as running.
Definition BaseThread.h:319
void MarkSetupComplete() noexcept
Mark the setup as complete.
Definition BaseThread.h:299
static void ThreadEntry(OS_Ulong instanceAddress)
Thread entry that will be running.
Definition BaseThread.cpp:208
OS_Thread * GetThreadId() noexcept
Get the pointer to the thread.
Definition BaseThread.h:65
bool IsThreadCreated() noexcept
Definition BaseThread.h:117
void ClearThreadStepInDelay() noexcept
Clear the stop request for the thread.
Definition BaseThread.h:344
bool IsThreadStopped() const noexcept
Definition BaseThread.h:123
void ClearThreadStopRequested() noexcept
Clear the stop request for the thread.
Definition BaseThread.h:334
bool StartThreadAndWaitToVerify(uint32_t startTimeoutMsec=1000)
[BLOCKING] Signals a BaseThread to start and waits to make sure it's started within the given timeout...
Definition BaseThread.cpp:270
void ClearCleanupComplete() noexcept
Clear the cleanup flag.
Definition BaseThread.h:314
bool Stop() noexcept
Stops the thread.
Definition BaseThread.cpp:198
BaseThread & operator=(const BaseThread &)=delete
The assignment operator constructor is deleted to avoid copying instances.
void ClearSetupComplete() noexcept
Clear the setup completion flag.
Definition BaseThread.h:304
virtual ~BaseThread() noexcept
The destructor de-initializes the singleton. It is not likely to be called in released products,...
Definition BaseThread.cpp:52
bool Suspend() noexcept
Suspend the underlying thread OS task.
Definition BaseThread.cpp:127
std::atomic< bool > threadStepInDelay
Definition BaseThread.h:359
uint32_t minTimestampBeforeNextStep
Definition BaseThread.h:356
SignalSemaphore signalSemaphore
Definition BaseThread.h:350
const char * GetThreadName() noexcept
Returns the Base thread name.
Definition BaseThread.cpp:65
void MarkCleanupComplete() noexcept
Mark the cleanup as complete.
Definition BaseThread.h:309
bool Start() noexcept
Starts the thread.
Definition BaseThread.cpp:176
SignalSemaphore class for managing a named semaphore.
Definition SignalSemaphore.h:21
unsigned int OS_Uint
Definition os_cmsis.h:36
unsigned long OS_Ulong
Definition os_cmsis.h:35
osThreadId_t OS_Thread
Definition os_cmsis.h:27