ipc::Queue
Queue
#include <icy/ipc.h>Subclassed by:
SyncQueue< TAction >
IPC queue is for safely passing templated actions between threads and processes.
Public Methods
| Return | Name | Description |
|---|---|---|
Queue inline | ||
void | push virtual inline | Pushes an action onto the queue and triggers a post notification. Takes ownership of action; the queue deletes it after execution. Thread-safe. |
TAction * | pop virtual inline | Removes and returns the next action from the front of the queue. The caller takes ownership of the returned pointer. Thread-safe. |
void | runSync virtual inline | Drains the queue by invoking and deleting every pending action in order. Must be called from the thread that owns the event loop. |
void | close virtual inline | Closes the underlying notification handle. No-op in the base implementation. |
void | post virtual inline | Signals the event loop that new actions are available. No-op in the base implementation. |
void | waitForSync inline | Blocks the calling thread until the queue is empty or the timeout elapses. Polls every 10 ms. Logs a warning if the timeout is reached. |
Queue
inline
inline Queue()push
virtual inline
virtual inline void push(TAction * action)Pushes an action onto the queue and triggers a post notification. Takes ownership of action; the queue deletes it after execution. Thread-safe.
Parameters
actionHeap-allocated action to enqueue.
pop
virtual inline
virtual inline TAction * pop()Removes and returns the next action from the front of the queue. The caller takes ownership of the returned pointer. Thread-safe.
Returns
Pointer to the next action, or nullptr if the queue is empty.
runSync
virtual inline
virtual inline void runSync()Drains the queue by invoking and deleting every pending action in order. Must be called from the thread that owns the event loop.
close
virtual inline
virtual inline void close()Closes the underlying notification handle. No-op in the base implementation.
post
virtual inline
virtual inline void post()Signals the event loop that new actions are available. No-op in the base implementation.
waitForSync
inline
inline void waitForSync(std::chrono::milliseconds timeout)Blocks the calling thread until the queue is empty or the timeout elapses. Polls every 10 ms. Logs a warning if the timeout is reached.
Parameters
timeoutMaximum time to wait (default: 5000 ms).
Protected Attributes
_mutex
std::mutex _mutex_actions
std::deque< TAction * > _actions