RunnableQueue
RunnableQueue
#include <icy/queue.h>Inherits:
Queue< T * >,RunnableSubclassed by:AsyncQueue< IPacket >,AsyncQueue< PacketT >,PlanarAudioPacket >,AsyncQueue< VisionFramePacket >,SyncQueue< IPacket >,AsyncQueue< T >,SyncQueue< T >
Queue of runnable tasks for sequential execution.
Public Attributes
| Return | Name | Description |
|---|---|---|
std::function< void(T &)> | ondispatch | The default dispatch function. Must be set before the queue is running. |
ondispatch
std::function< void(T &)> ondispatchThe default dispatch function. Must be set before the queue is running.
Public Methods
| Return | Name | Description |
|---|---|---|
RunnableQueue inline | #### Parameters | |
void | push virtual inline | Push an item onto the queue. The queue takes ownership of the item pointer. |
void | flush virtual inline | Flush all outgoing items. |
void | clear inline | |
void | run virtual inline | Called asynchronously to dispatch queued items. If not timeout is set this method blocks until cancel() is called, otherwise runTimeout() will be called. |
void | runTimeout virtual inline | Called asynchronously to dispatch queued items until the queue is empty or the timeout expires. Pseudo protected for std::bind compatability. |
void | dispatch virtual inline | Dispatch a single item to listeners. |
int | timeout inline | #### Returns |
void | setTimeout inline | Sets the dispatch timeout. Must only be called when the queue is empty. |
size_t | dropped const inline | #### Returns |
RunnableQueue
inline
inline RunnableQueue(int limit, int timeout)Parameters
limitMaximum number of queued items; oldest are purged when exceeded (0 = unlimited).timeoutDispatch 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
millisecondsNew timeout in milliseconds.
Exceptions
std::logic_errorif the queue is non-empty.
dropped
const inline
inline size_t dropped() constReturns
Number of items purged because the queue limit was exceeded.
Protected Attributes
_limit
int _limit_timeout
int _timeout_dropped
size_t _dropped = 0Protected Methods
| Return | Name | Description |
|---|---|---|
RunnableQueue | Deleted constructor. | |
RunnableQueue | Deleted constructor. | |
T * | popNext virtual inline | Pops the next waiting item. |
bool | dispatchNext virtual inline | Pops and dispatches the next waiting item. |
RunnableQueue
RunnableQueue(const RunnableQueue &) = deleteDeleted constructor.
RunnableQueue
RunnableQueue(RunnableQueue &&) = deleteDeleted 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.
