Class storing message bus messages. More...
#include <eagine/message_bus/message.hpp>
Public Types | |
using | fetch_handler = callable_ref< bool(message_id, message_age, const message_view &)> |
Alias for the message fetch handler. More... | |
using | cleanup_predicate = callable_ref< bool(message_age)> |
Alias for message cleanup callable predicate. More... | |
Public Member Functions | |
message_storage () | |
Default constructor. | |
auto | empty () const noexcept -> bool |
Indicates if the storage is empty. | |
auto | count () const noexcept -> span_size_t |
Returns the coung of messages in the storage. | |
void | push (message_id msg_id, const message_view &message) |
Pushes a message into this storage. | |
template<typename Function > | |
auto | push_if (Function function, span_size_t req_size=0) -> bool |
Pushes a new message and lets a function to fill it. More... | |
auto | fetch_all (fetch_handler handler) -> bool |
Fetches all currently stored messages and calls handler on them. | |
void | cleanup (cleanup_predicate predicate) |
Removes messages based on the result of the specified predicate. | |
Class storing message bus messages.
Alias for message cleanup callable predicate.
The return value indicates if a message should be removed.
using eagine::msgbus::message_storage::fetch_handler = callable_ref<bool(message_id, message_age, const message_view&)> |
Alias for the message fetch handler.
The return value indicates if the message is considered handled and should be removed.
|
inline |
Pushes a new message and lets a function to fill it.
The function's Boolean return value indicates if the message should be kept.