Seastar
High performance C++ framework for concurrent servers
|
Container for elements with support for expiration of entries.
OnExpiry is a functor which will be called with a reference to T right before it expires. T is removed and destroyed from the container immediately after OnExpiry returns. OnExpiry callback must not modify the container, it can only modify its argument.
The container can only be moved before any elements are pushed.
#include <seastar/core/expiring_fifo.hh>
Public Types | |
using | clock = Clock |
using | time_point = typename Clock::time_point |
Public Member Functions | |
expiring_fifo (OnExpiry on_expiry) noexcept(std::is_nothrow_move_constructible_v< OnExpiry >) | |
expiring_fifo (expiring_fifo &&o) noexcept | |
expiring_fifo & | operator= (expiring_fifo &&o) noexcept |
bool | empty () const noexcept |
operator bool () const noexcept | |
Equivalent to !empty() | |
T & | front () noexcept |
const T & | front () const noexcept |
size_t | size () const noexcept |
void | reserve (size_t size) |
void | push_back (const T &payload) |
void | push_back (T &&payload) |
void | push_back (T &&payload, time_point timeout) |
void | pop_front () noexcept |
|
inlinenoexcept |
Checks if container contains any elements
|
inlinenoexcept |
Returns a reference to the element in the front. Valid only when !empty().
|
inlinenoexcept |
Returns a reference to the element in the front. Valid only when !empty().
|
inlinenoexcept |
Removes the element at the front. Can be called only if !empty().
|
inline |
Adds element to the back of the queue. The element will never expire.
|
inline |
Adds element to the back of the queue. The element will never expire.
|
inline |
Adds element to the back of the queue. The element will expire when timeout is reached, unless it is time_point::max(), in which case it never expires.
|
inline |
Reserves storage in the container for at least 'size' elements. Note that expired elements may also take space when they are not in the front of the queue.
Doesn't give any guarantees about exception safety of subsequent push_back().
|
inlinenoexcept |
Returns the number of elements contained.