Home
Base module

SyncPacketQueue

Synchronized packet queue for event loop integration.

SyncPacketQueue

#include <icy/packetqueue.h>
template<class T = IPacket>
class SyncPacketQueue

Defined in src/base/include/icy/packetqueue.h:31

Inherits: SyncQueue< IPacket >, PacketProcessor

Synchronized packet queue for event loop integration.

List of all members

NameKindOwner
emittervariableDeclared here
SyncPacketQueuefunctionDeclared here
SyncPacketQueuefunctionDeclared here
~SyncPacketQueuefunctionDeclared here
processfunctionDeclared here
acceptsfunctionDeclared here
retentionfunctionDeclared here
dispatchfunctionDeclared here
onStreamStateChangefunctionDeclared here
QueuetypedefDeclared here
ProcessortypedefDeclared here
SyncQueuefunctionInherited from SyncQueue
~SyncQueuefunctionInherited from SyncQueue
pushfunctionInherited from SyncQueue
cancelfunctionInherited from SyncQueue
syncfunctionInherited from SyncQueue
_syncvariableInherited from SyncQueue
QueuetypedefInherited from SyncQueue
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
PacketProcessorfunctionInherited from PacketProcessor
processfunctionInherited from PacketProcessor
acceptsfunctionInherited from PacketProcessor
operator<<functionInherited from PacketProcessor
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
~PacketStreamAdapterfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
emitfunctionInherited from PacketStreamAdapter
getEmitterfunctionInherited from PacketStreamAdapter
retentionfunctionInherited from PacketStreamAdapter
onStreamStateChangefunctionInherited from PacketStreamAdapter
_emittervariableInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter
PacketStreamAdapterfunctionInherited from PacketStreamAdapter
operator=functionInherited from PacketStreamAdapter

Inherited from SyncQueue

KindNameDescription
functionSyncQueue inline
function~SyncQueue virtual inlineDestruction is deferred to allow enough time for all callbacks to return.
functionpush virtual inline overridePushes an item onto the queue and wakes the event loop for dispatch. Ownership of item is transferred to the queue.
functioncancel virtual inline overrideCancels the queue and its underlying synchronizer.
functionsync inline
variable_sync
typedefQueue

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

Inherited from PacketProcessor

KindNameDescription
functionPacketProcessor inline
functionprocess virtualThis method performs processing on the given packet and emits the result.
functionaccepts virtual inlineThis method ensures compatibility with the given packet type. Return false to reject the packet.
functionoperator<< virtual inlineStream operator alias for process()

Inherited from PacketStreamAdapter

KindNameDescription
functionPacketStreamAdapterConstruct the adapter, binding it to the given packet signal.
function~PacketStreamAdapter virtual inline
functionemit virtualEmit a mutable raw buffer as a packet.
functionemit virtualEmit a read-only raw buffer as a packet (data is copied internally).
functionemit virtualEmit a string as a packet (data is copied internally).
functionemit virtualEmit a flag-only packet carrying no payload data.
functionemit virtualEmit an existing packet directly onto the outgoing signal.
functiongetEmitterReturns a reference to the outgoing packet signal.
functionretention virtual constReturns how this adapter treats incoming packet lifetime. Most adapters are synchronous and therefore only borrow the packet for the current call chain. Queue-style adapters override this to advertise that they clone before deferred use. Callers may treat the first adapter reporting Cloned or Retained as the explicit ownership boundary in the stream graph.
functiononStreamStateChange virtual inlineCalled by the PacketStream to notify when the internal Stream state changes. On receiving the Stopped state, it is the responsibility of the adapter to have ceased all outgoing packet transmission, especially in multi-thread scenarios.
variable_emitter
functionPacketStreamAdapterNonCopyable and NonMovable.
functionoperator=Deleted assignment operator.
functionPacketStreamAdapterDeleted constructor.
functionoperator=Deleted assignment operator.

Public Attributes

ReturnNameDescription
PacketSignalemitter

emitter

PacketSignal emitter

Defined in src/base/include/icy/packetqueue.h:72

Public Methods

ReturnNameDescription
SyncPacketQueue inline
SyncPacketQueue inlineUses the default libuv event loop.
voidprocess virtual inline overrideClones the incoming packet and pushes it onto the queue for synchronized dispatch. This queue is therefore an explicit PacketStream ownership boundary. Drops the packet with a warning if the queue has been cancelled.
boolaccepts virtual inline overrideReturns true if the packet can be cast to type T.
PacketRetentionretention virtual const inline overrideReturns how this adapter treats incoming packet lifetime. Most adapters are synchronous and therefore only borrow the packet for the current call chain. Queue-style adapters override this to advertise that they clone before deferred use. Callers may treat the first adapter reporting Cloned or Retained as the explicit ownership boundary in the stream graph.

SyncPacketQueue

inline

inline SyncPacketQueue(uv::Loop * loop, int maxSize = 1024)

Defined in src/base/include/icy/packetqueue.h:40

Parameters

  • loop Event loop to synchronize dispatch onto.

  • maxSize Maximum number of queued packets before oldest are dropped.


SyncPacketQueue

inline

inline SyncPacketQueue(int maxSize = 1024)

Defined in src/base/include/icy/packetqueue.h:48

Uses the default libuv event loop.

Parameters

  • maxSize Maximum number of queued packets before oldest are dropped.

process

virtual inline override

virtual inline void process(IPacket & packet) override

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

Clones the incoming packet and pushes it onto the queue for synchronized dispatch. This queue is therefore an explicit PacketStream ownership boundary. Drops the packet with a warning if the queue has been cancelled.

Parameters

  • packet Incoming packet to enqueue.
Reimplements

accepts

virtual inline override

virtual inline bool accepts(IPacket * packet) override

Defined in src/base/include/icy/packetqueue.h:65

Returns true if the packet can be cast to type T.

Parameters

  • packet Packet to test.

Returns

True if dynamic_cast<T*>(packet) succeeds.

Reimplements

retention

virtual const inline override

virtual inline PacketRetention retention() const override

Defined in src/base/include/icy/packetqueue.h:67

Returns how this adapter treats incoming packet lifetime. Most adapters are synchronous and therefore only borrow the packet for the current call chain. Queue-style adapters override this to advertise that they clone before deferred use. Callers may treat the first adapter reporting Cloned or Retained as the explicit ownership boundary in the stream graph.

Reimplements

Protected Methods

ReturnNameDescription
voiddispatch virtual inline overrideEmits the packet to downstream processors from the event loop thread.
voidonStreamStateChange virtual inline overrideCancels the queue on Closed or [Error](icy-Error.html#error) stream state transitions.

dispatch

virtual inline override

virtual inline void dispatch(T & packet) override

Defined in src/base/include/icy/packetqueue.h:77

Emits the packet to downstream processors from the event loop thread.

Parameters

  • packet Packet to dispatch.
Reimplements

onStreamStateChange

virtual inline override

virtual inline void onStreamStateChange(const PacketStreamState &) override

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

Cancels the queue on Closed or [Error](icy-Error.html#error) stream state transitions.

Parameters

  • state New stream state.
Reimplements

Public Types

NameDescription
Queue
Processor

Queue

using Queue = SyncQueue< T >

Defined in src/base/include/icy/packetqueue.h:35


Processor

using Processor = PacketProcessor

Defined in src/base/include/icy/packetqueue.h:36