MT#63171 introduce AmEventQueueThread

New class inheriting from AmEventQueueBase to be used in threads that
run in a loop processing events until thread shutdown is requested.

Change-Id: Ib63837997659a944fc217712ff2472c7900e7525
mr13.5
Richard Fuchs 6 months ago
parent 5234af1215
commit ef2b5e47b1

@ -118,5 +118,32 @@ public:
AmEventQueue(AmEventHandler* handler) : AmEventQueueBase(handler, _mut, _cond) {}
};
/**
* \brief Thread-based asynchronous event queue
*
* This class can be used to run a thread based on an event
* queue.
*/
class AmEventQueueThread
: public AmThread,
public AmEventQueueBase
{
protected:
// mutex must be held
bool shouldSleep() const {
return !stop_requested_unlocked() && AmEventQueueBase::shouldSleep();
}
public:
AmEventQueueThread(AmEventHandler* handler)
: AmEventQueueBase(handler, run_mut, run_cond)
{}
virtual void on_destroy() {
stop();
join();
}
};
#endif

Loading…
Cancel
Save