Home
Base module

AsyncPacketQueue

Thread-based asynchronous packet dispatch queue.

AsyncPacketQueue

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

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

Inherits: AsyncQueue< IPacket >, PacketProcessor

Thread-based asynchronous packet dispatch queue.

List of all members

NameKindOwner
emittervariableDeclared here
AsyncPacketQueuefunctionDeclared here
~AsyncPacketQueuefunctionDeclared here
closefunctionDeclared here
processfunctionDeclared here
acceptsfunctionDeclared here
retentionfunctionDeclared here
dispatchfunctionDeclared here
onStreamStateChangefunctionDeclared here
QueuetypedefDeclared here
ProcessortypedefDeclared here
AsyncQueuefunctionInherited from AsyncQueue
cancelfunctionInherited from AsyncQueue
_threadvariableInherited from AsyncQueue
~AsyncQueuefunctionInherited from AsyncQueue
QueuetypedefInherited from AsyncQueue
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 AsyncQueue

KindNameDescription
functionAsyncQueue inline
functioncancel virtual inline overrideCancels the queue and joins the dispatch thread.
variable_thread
function~AsyncQueue virtual inline
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:180

Public Methods

ReturnNameDescription
AsyncPacketQueue inline
voidclose virtual inlineFlushes remaining packets, cancels the queue, and joins the dispatch thread.
voidprocess virtual inline overrideClones the incoming packet and pushes it onto the async queue. 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.

AsyncPacketQueue

inline

inline AsyncPacketQueue(int maxSize = 1024)

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

Parameters

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

close

virtual inline

virtual inline void close()

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

Flushes remaining packets, cancels the queue, and joins the dispatch thread.


process

virtual inline override

virtual inline void process(IPacket & packet) override

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

Clones the incoming packet and pushes it onto the async queue. 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:173

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:175

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 async thread.
voidonStreamStateChange virtual inline overrideCloses the queue on [Error](icy-Error.html#error) or Closed stream state transitions.

dispatch

virtual inline override

virtual inline void dispatch(T & packet) override

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

Emits the packet to downstream processors from the async 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:189

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

Parameters

  • state New stream state.
Reimplements
Reimplemented by

Public Types

NameDescription
Queue
Processor

Queue

using Queue = AsyncQueue< T >

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


Processor

using Processor = PacketProcessor

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