Home
Base module

RunnableQueue

Queue of runnable tasks for sequential execution.

RunnableQueue

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

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

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

Queue of runnable tasks for sequential execution.

List of all members

NameKindOwner
ondispatchvariableDeclared here
RunnableQueuefunctionDeclared here
~RunnableQueuefunctionDeclared here
pushfunctionDeclared here
flushfunctionDeclared here
clearfunctionDeclared here
runfunctionDeclared here
runTimeoutfunctionDeclared here
dispatchfunctionDeclared here
timeoutfunctionDeclared here
setTimeoutfunctionDeclared here
droppedfunctionDeclared here
_limitvariableDeclared here
_timeoutvariableDeclared here
_droppedvariableDeclared here
RunnableQueuefunctionDeclared here
operator=functionDeclared here
RunnableQueuefunctionDeclared here
operator=functionDeclared here
popNextfunctionDeclared here
dispatchNextfunctionDeclared here
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 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 Attributes

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

ondispatch

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

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

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

Public Methods

ReturnNameDescription
RunnableQueue inline
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 inline overrideCalled 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
voidsetTimeout inlineSets the dispatch timeout. Must only be called when the queue is empty.
size_tdropped const inline

RunnableQueue

inline

inline RunnableQueue(int limit = 2048, int timeout = 0)

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

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)

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

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

Reimplemented by

flush

virtual inline

virtual inline void flush()

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

Flush all outgoing items.


clear

inline

inline void clear()

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


run

virtual inline override

virtual inline void run() override

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

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

Reimplements

runTimeout

virtual inline

virtual inline void runTimeout()

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

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)

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

Dispatch a single item to listeners.

Reimplemented by

timeout

inline

inline int timeout()

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

Returns

Current dispatch timeout in milliseconds.


setTimeout

inline

inline void setTimeout(int milliseconds)

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

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

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

Returns

Number of items purged because the queue limit was exceeded.

Protected Attributes

ReturnNameDescription
int_limit
int_timeout
size_t_dropped

_limit

int _limit

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


_timeout

int _timeout

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


_dropped

size_t _dropped = 0

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

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

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

Deleted constructor.


RunnableQueue

RunnableQueue(RunnableQueue &&) = delete

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

Deleted constructor.


popNext

virtual inline

virtual inline T * popNext()

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

Pops the next waiting item.

Reimplemented by

dispatchNext

virtual inline

virtual inline bool dispatchNext()

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

Pops and dispatches the next waiting item.