Class TimersManager::TimersHeap

Nested Relationships

This class is a nested type of Class TimersManager.

Class Documentation

class TimersHeap

This class is the equivalent of WeakTimersHeap but with ownership of the timers. It can be generated by locking the weak version. It provides operations to manipulate the heap. This class is not thread safe and requires external mutexes to protect its usage.

Public Functions

inline bool add_timer(TimerPtr timer)

Try to add a new timer to the heap. After the addition, the heap property is preserved.

Parameters:

timer – new timer to add.

Returns:

true if timer has been added, false if it was already there.

inline bool remove_timer(TimerPtr timer)

Try to remove a timer from the heap. After the removal, the heap property is preserved.

Parameters:

timer – timer to remove.

Returns:

true if timer has been removed, false if it was not there.

inline TimerPtr &front()

Returns a reference to the front element.

Returns:

reference to front element.

inline const TimerPtr &front() const

Returns a const reference to the front element.

Returns:

const reference to front element.

inline bool empty() const

Returns whether the heap is empty or not.

Returns:

true if the heap is empty.

inline size_t size() const

Returns the size of the heap.

Returns:

the number of valid timers in the heap.

inline size_t get_number_ready_timers() const

Get the number of timers that are currently ready.

Returns:

size_t number of ready timers.

inline void heapify_root()

Restore a valid heap after the root value has been replaced (e.g. timer triggered).

inline void heapify()

Completely restores the structure to a valid heap.

inline void clear_timers_on_reset_callbacks()

Helper function to clear the “on_reset_callback” on all associated timers.

Friends

friend TimersHeap validate_and_lock()

Friend declaration to allow the validate_and_lock() function to access the underlying heap container.

friend void store(const TimersHeap &heap)

Friend declaration to allow the store() function to access the underlying heap container.