Home
Base module

ipc::Queue

IPC queue is for safely passing templated actions between threads and processes.

Queue

#include <icy/ipc.h>
template<typename TAction = ipc::Action>
class Queue

Defined in src/base/include/icy/ipc.h:57

Subclassed by: SyncQueue< TAction >

IPC queue is for safely passing templated actions between threads and processes.

List of all members

NameKindOwner
QueuefunctionDeclared here
~QueuefunctionDeclared here
pushfunctionDeclared here
popfunctionDeclared here
runSyncfunctionDeclared here
closefunctionDeclared here
postfunctionDeclared here
waitForSyncfunctionDeclared here
_mutexvariableDeclared here
_actionsvariableDeclared here

Public Methods

ReturnNameDescription
Queue inline
voidpush virtual inlinePushes 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 inlineRemoves and returns the next action from the front of the queue. The caller takes ownership of the returned pointer. Thread-safe.
voidrunSync virtual inlineDrains the queue by invoking and deleting every pending action in order. Must be called from the thread that owns the event loop.
voidclose virtual inlineCloses the underlying notification handle. No-op in the base implementation.
voidpost virtual inlineSignals the event loop that new actions are available. No-op in the base implementation.
voidwaitForSync inlineBlocks 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()

Defined in src/base/include/icy/ipc.h:60


push

virtual inline

virtual inline void push(TAction * action)

Defined in src/base/include/icy/ipc.h:68

Pushes an action onto the queue and triggers a post notification. Takes ownership of action; the queue deletes it after execution. Thread-safe.

Parameters

  • action Heap-allocated action to enqueue.

pop

virtual inline

virtual inline TAction * pop()

Defined in src/base/include/icy/ipc.h:81

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()

Defined in src/base/include/icy/ipc.h:93

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()

Defined in src/base/include/icy/ipc.h:103

Closes the underlying notification handle. No-op in the base implementation.

Reimplemented by

post

virtual inline

virtual inline void post()

Defined in src/base/include/icy/ipc.h:106

Signals the event loop that new actions are available. No-op in the base implementation.

Reimplemented by

waitForSync

inline

inline void waitForSync(std::chrono::milliseconds timeout = std::chrono::milliseconds(5000))

Defined in src/base/include/icy/ipc.h:111

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

  • timeout Maximum time to wait (default: 5000 ms).

Protected Attributes

ReturnNameDescription
std::mutex_mutex
std::deque< TAction * >_actions

_mutex

std::mutex _mutex

Defined in src/base/include/icy/ipc.h:127


_actions

std::deque< TAction * > _actions

Defined in src/base/include/icy/ipc.h:128