mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-07-24 15:27:41 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user