refactor(WorkQueue): move SignalWorkerThread out-of-line

Move the helper from the header into WorkQueue.cpp. Drop the
SignalWorkerThread() call from request_stop() — request_stop sets
_should_exit but the worker is woken up via the existing exit path
in Detach already, so the extra signal here is redundant.
This commit is contained in:
Julian Oes
2026-04-28 07:04:13 +12:00
committed by Ramon Roche
parent 339291bec9
commit da52562708
2 changed files with 11 additions and 9 deletions

View File

@@ -69,7 +69,7 @@ public:
void Run();
void request_stop() { _should_exit.store(true); SignalWorkerThread(); }
void request_stop() { _should_exit.store(true); }
void print_status(bool last = false);
@@ -80,14 +80,7 @@ private:
bool should_exit() const { return _should_exit.load(); }
inline void SignalWorkerThread()
{
int sem_val;
if (px4_sem_getvalue(&_process_lock, &sem_val) == 0 && sem_val <= 0) {
px4_sem_post(&_process_lock);
}
}
inline void SignalWorkerThread();
#ifdef __PX4_NUTTX
// In NuttX work can be enqueued from an ISR

View File

@@ -144,6 +144,15 @@ void WorkQueue::Add(WorkItem *item)
SignalWorkerThread();
}
void WorkQueue::SignalWorkerThread()
{
int sem_val;
if (px4_sem_getvalue(&_process_lock, &sem_val) == 0 && sem_val <= 0) {
px4_sem_post(&_process_lock);
}
}
void WorkQueue::Remove(WorkItem *item)
{
work_lock();