Home
Base module

SyncQueue

SyncQueue extends Synchronizer to implement a syn

SyncQueue

#include <icy/queue.h>
template<class T>
class SyncQueue

Defined in src/base/include/icy/queue.h:285

Inherits: RunnableQueue< T > Subclassed by: SyncPacketQueue< T >

SyncQueue extends Synchronizer to implement a synchronized FIFO queue which receives T objects from any thread and synchronizes them for safe consumption by the associated event loop.

List of all members

NameKindOwner
SyncQueuefunctionDeclared here
~SyncQueuefunctionDeclared here
pushfunctionDeclared here
cancelfunctionDeclared here
syncfunctionDeclared here
_syncvariableDeclared here
QueuetypedefDeclared here
ondispatchvariableInherited from RunnableQueue
RunnableQueuefunctionInherited from RunnableQueue
~RunnableQueuefunctionInherited from RunnableQueue
pushfunctionInherited from RunnableQueue
flushfunctionInherited from RunnableQueue
clearfunctionInherited from RunnableQueue
runfunctionInherited from RunnableQueue
runTimeoutfunctionInherited from RunnableQueue
dispatchfunctionInherited from RunnableQueue
timeoutfunctionInherited from RunnableQueue
setTimeoutfunctionInherited from RunnableQueue
droppedfunctionInherited from RunnableQueue
_limitvariableInherited from RunnableQueue
_timeoutvariableInherited from RunnableQueue
_droppedvariableInherited from RunnableQueue
RunnableQueuefunctionInherited from RunnableQueue
operator=functionInherited from RunnableQueue
RunnableQueuefunctionInherited from RunnableQueue
operator=functionInherited from RunnableQueue
popNextfunctionInherited from RunnableQueue
dispatchNextfunctionInherited from RunnableQueue
pushfunctionInherited from Queue
pushfunctionInherited from Queue
emptyfunctionInherited from Queue
frontfunctionInherited from Queue
backfunctionInherited from Queue
popfunctionInherited from Queue
sortfunctionInherited from Queue
sizefunctionInherited from Queue
queuefunctionInherited from Queue
_queuevariableInherited from Queue
_mutexvariableInherited from Queue
RunnablefunctionInherited from Runnable
~RunnablefunctionInherited from Runnable
runfunctionInherited from Runnable
cancelfunctionInherited from Runnable
cancelledfunctionInherited from Runnable
exitvariableInherited from Runnable

Inherited from RunnableQueue

KindNameDescription
variableondispatchThe default dispatch function. Must be set before the queue is running.
functionRunnableQueue inline
function~RunnableQueue virtual inline
functionpush virtual inlinePush an item onto the queue. The queue takes ownership of the item pointer.
functionflush virtual inlineFlush all outgoing items.
functionclear inline
functionrun virtual inline overrideCalled asynchronously to dispatch queued items. If not timeout is set this method blocks until cancel() is called, otherwise runTimeout() will be called.
functionrunTimeout virtual inlineCalled asynchronously to dispatch queued items until the queue is empty or the timeout expires. Pseudo protected for std::bind compatability.
functiondispatch virtual inlineDispatch a single item to listeners.
functiontimeout inline
functionsetTimeout inlineSets the dispatch timeout. Must only be called when the queue is empty.
functiondropped const inline
variable_limit
variable_timeout
variable_dropped
functionRunnableQueueDeleted constructor.
functionoperator=Deleted assignment operator.
functionRunnableQueueDeleted constructor.
functionoperator=Deleted assignment operator.
functionpopNext virtual inlinePops the next waiting item.
functiondispatchNext virtual inlinePops and dispatches the next waiting item.

Inherited from Queue

KindNameDescription
functionpush inlineAppends an item to the back of the queue (thread-safe).
functionpush inlineAppends an item to the back of the queue by move (thread-safe).
functionempty const inline
functionfront const inline
functionback const inline
functionpop inlineRemoves the front item from the queue (thread-safe).
functionsort inlineSorts all queued items using the given comparator (thread-safe).
functionsize const inline
functionqueue const inline
variable_queue
variable_mutex

Inherited from Runnable

KindNameDescription
functionRunnable inline
function~Runnable virtualDefaulted destructor.
functionrun virtualThe run method will be called by the asynchronous context.
functioncancel virtual inlineCancel the current task. The run() method should return ASAP.
functioncancelled virtual const inlineReturns true when the task has been cancelled.
variableexit

Public Methods

ReturnNameDescription
SyncQueue inline
~SyncQueue virtual inlineDestruction is deferred to allow enough time for all callbacks to return.
voidpush virtual inline overridePushes an item onto the queue and wakes the event loop for dispatch. Ownership of item is transferred to the queue.
voidcancel virtual inline overrideCancels the queue and its underlying synchronizer.
Synchronizer &sync inline

SyncQueue

inline

inline SyncQueue(uv::Loop * loop, int limit = 2048, int timeout = 20)

Defined in src/base/include/icy/queue.h:293

Parameters

  • loop Event loop used by the internal [Synchronizer](icy-Synchronizer.html#synchronizer).

  • limit Maximum queued items; oldest are dropped when exceeded.

  • timeout Dispatch timeout in milliseconds passed to [RunnableQueue](icy-RunnableQueue.html#runnablequeue).


~SyncQueue

virtual inline

virtual inline ~SyncQueue()

Defined in src/base/include/icy/queue.h:301

Destruction is deferred to allow enough time for all callbacks to return.


push

virtual inline override

virtual inline void push(T * item) override

Defined in src/base/include/icy/queue.h:308

Pushes an item onto the queue and wakes the event loop for dispatch. Ownership of item is transferred to the queue.

Parameters

  • item Heap-allocated item to enqueue; the queue takes ownership.
Reimplements

cancel

virtual inline override

virtual inline void cancel(bool flag = true) override

Defined in src/base/include/icy/queue.h:316

Cancels the queue and its underlying synchronizer.

Parameters

  • flag True to cancel, false to un-cancel.
Reimplements

sync

inline

inline Synchronizer & sync()

Defined in src/base/include/icy/queue.h:326

Returns

Reference to the underlying [Synchronizer](icy-Synchronizer.html#synchronizer) handle.

Protected Attributes

ReturnNameDescription
Synchronizer_sync

_sync

Synchronizer _sync

Defined in src/base/include/icy/queue.h:329

Public Types

NameDescription
Queue

Queue

using Queue = RunnableQueue< T >

Defined in src/base/include/icy/queue.h:288