Base module

RunnableQueue

[Queue]({#ref classicy_1_1Queue #}) of runnable tasks for sequential execution.

RunnableQueue

#include <icy/queue.h>

Inherits: Queue< T * >, Runnable Subclassed by: AsyncQueue< IPacket >, AsyncQueue< PacketT >, PlanarAudioPacket >, PlanarVideoPacket >, SyncQueue< IPacket >, AsyncQueue< T >, SyncQueue< T >

Queue of runnable tasks for sequential execution.

Public Attributes

ReturnNameDescription
std::function< void(T &)>ondispatchThe default dispatch function. Must be set before the queue is running.

ondispatch

std::function< void(T &)> ondispatch

The default dispatch function. Must be set before the queue is running.

Public Methods

ReturnNameDescription
RunnableQueue inline#### Parameters
voidpush virtual inlinePush an item onto the queue. The queue takes ownership of the item pointer.
voidflush virtual inlineFlush all outgoing items.
voidclear inline
voidrun virtual inlineCalled asynchronously to dispatch queued items. If not timeout is set this method blocks until cancel() is called, otherwise runTimeout() will be called.
voidrunTimeout virtual inlineCalled asynchronously to dispatch queued items until the queue is empty or the timeout expires. Pseudo protected for std::bind compatability.
voiddispatch virtual inlineDispatch a single item to listeners.
inttimeout inline#### Returns
voidsetTimeout inlineSets the dispatch timeout. Must only be called when the queue is empty.
size_tdropped const inline#### Returns

RunnableQueue

inline

inline RunnableQueue(int limit, int timeout)

Parameters

  • limit Maximum number of queued items; oldest are purged when exceeded (0 = unlimited).

  • timeout Dispatch timeout in milliseconds; 0 means run until cancel() is called.


push

virtual inline

virtual inline void push(T * item)

Push an item onto the queue. The queue takes ownership of the item pointer.


flush

virtual inline

virtual inline void flush()

Flush all outgoing items.


clear

inline

inline void clear()

run

virtual inline

virtual inline void run()

Called asynchronously to dispatch queued items. If not timeout is set this method blocks until cancel() is called, otherwise runTimeout() will be called.


runTimeout

virtual inline

virtual inline void runTimeout()

Called asynchronously to dispatch queued items until the queue is empty or the timeout expires. Pseudo protected for std::bind compatability.


dispatch

virtual inline

virtual inline void dispatch(T & item)

Dispatch a single item to listeners.


timeout

inline

inline int timeout()

Returns

Current dispatch timeout in milliseconds.


setTimeout

inline

inline void setTimeout(int milliseconds)

Sets the dispatch timeout. Must only be called when the queue is empty.

Parameters

  • milliseconds New timeout in milliseconds.

Exceptions

  • std::logic_error if the queue is non-empty.

dropped

const inline

inline size_t dropped() const

Returns

Number of items purged because the queue limit was exceeded.

Protected Attributes

ReturnNameDescription
int_limit
int_timeout
size_t_dropped

_limit

int _limit

_timeout

int _timeout

_dropped

size_t _dropped = 0

Protected Methods

ReturnNameDescription
RunnableQueueDeleted constructor.
RunnableQueueDeleted constructor.
T *popNext virtual inlinePops the next waiting item.
booldispatchNext virtual inlinePops and dispatches the next waiting item.

RunnableQueue

RunnableQueue(const RunnableQueue &) = delete

Deleted constructor.


RunnableQueue

RunnableQueue(RunnableQueue &&) = delete

Deleted constructor.


popNext

virtual inline

virtual inline T * popNext()

Pops the next waiting item.


dispatchNext

virtual inline

virtual inline bool dispatchNext()

Pops and dispatches the next waiting item.