#include <icy/timedmanager.h>Inherits:
KeyedStore< TKey, TValue >
Timed pointer manager
Provides timed persistent data storage for class instances. TValue must implement the clone() method.
| Return | Name | Description |
|---|---|---|
TimedManager inline | Constructs a TimedManager and starts the internal expiry-check timer. | |
void | add inline | Add an item which will expire (and be deleted) after the specified timeout value. If the timeout is 0 the item will be stored indefinitely. The TimedManager assumes ownership of the given pointer. |
bool | expires virtual inline | Update the item expiry timeout. |
bool | expires virtual inline | Update the item expiry timeout. |
void | clear virtual inline | Removes all items and their associated timeouts. |
inline
inline TimedManager(uv::Loop * loop)Constructs a TimedManager and starts the internal expiry-check timer.
loop Event loop used by the internal timer (default: process-wide default loop).inline
inline void add(constTKey & key, std::unique_ptr< TValue > item, long timeout)Add an item which will expire (and be deleted) after the specified timeout value. If the timeout is 0 the item will be stored indefinitely. The TimedManager assumes ownership of the given pointer.
virtual inline
virtual inline bool expires(constTKey & key, long timeout)Update the item expiry timeout.
virtual inline
virtual inline bool expires(TValue * item, long timeout)Update the item expiry timeout.
virtual inline
virtual inline void clear()Removes all items and their associated timeouts.
std::mutex _tmutexTimeoutMap _timeoutsTimer _timer| Return | Name | Description |
|---|---|---|
bool | setTimeout virtual inline | Sets or removes the expiry timeout for a specific item pointer. If timeout > 0, starts a countdown; if timeout == 0, removes any existing timeout. |
void | onRemove virtual inline | Called when an item is removed from the collection. Erases the item's timeout entry and calls the base implementation. |
void | onTimeout virtual inline | Called when an item's timeout expires. Default implementation removes and deletes the item. |
void | onTimerUpdate inline | Internal timer callback; iterates all tracked timeouts and calls onTimeout() for any that have expired. |
virtual inline
virtual inline bool setTimeout(TValue * item, long timeout)Sets or removes the expiry timeout for a specific item pointer. If timeout > 0, starts a countdown; if timeout == 0, removes any existing timeout.
item Pointer to the managed item.
timeout Delay in milliseconds, or 0 to clear the timeout.
true on success.
std::logic_error if item is nullptr.virtual inline
virtual inline void onRemove(constTKey & key, TValue * item)Called when an item is removed from the collection. Erases the item's timeout entry and calls the base implementation.
key Key of the removed item.
item Pointer to the removed item.
virtual inline
virtual inline void onTimeout(TValue * item)Called when an item's timeout expires. Default implementation removes and deletes the item.
item Pointer to the expired item.inline
inline void onTimerUpdate()Internal timer callback; iterates all tracked timeouts and calls onTimeout() for any that have expired.
| Name | Description |
|---|---|
Base | |
TimeoutMap |
KeyedStore< TKey, TValue > Base()std::map< TValue *, Timeout > TimeoutMap()