CAF  0.17.2
Public Member Functions | Static Public Attributes | Friends | Related Functions | List of all members
caf::message_id Class Reference

Bundles various flags along with an optional request ID. More...

#include <message_id.hpp>

Inheritance diagram for caf::message_id:
caf::detail::comparable< message_id >

Public Member Functions

constexpr message_id ()
 Constructs a message ID for asynchronous messages with normal priority.
 
constexpr message_id (uint64_t value)
 
 message_id (const message_id &)=default
 
message_idoperator= (const message_id &)=default
 
constexpr uint64_t category () const noexcept
 Returns the message category, i.e., one of normal_message_category, upstream_message_category, downstream_message_category, or urgent_message_category.
 
constexpr message_id with_category (uint64_t x) const noexcept
 Returns a new message ID with given category.
 
constexpr bool is_async () const noexcept
 Returns whether a message is asynchronous, i.e., neither a request, nor a response, nor a stream message.
 
constexpr bool is_request () const noexcept
 Returns whether a message is a request.
 
constexpr bool is_response () const noexcept
 Returns whether a message is a response to a previously send request.
 
constexpr bool is_answered () const noexcept
 Returns whether a message is tagged as answered by the receiving actor.
 
constexpr bool is_urgent_message () const noexcept
 Returns whether category() == urgent_message_category.
 
constexpr bool is_normal_message () const noexcept
 Returns whether category() == normal_message_category.
 
constexpr bool is_stream_message () const noexcept
 Returns whether category() is an up- or downstream message.
 
constexpr bool is_upstream_message () const noexcept
 Returns whether category() == upstream_message_category.
 
constexpr bool is_downstream_message () const noexcept
 Returns whether category() == downstream_message_category.
 
constexpr message_id response_id () const noexcept
 Returns a response ID for the current request or an asynchronous ID with the same priority as this ID.
 
constexpr message_id request_id () const noexcept
 Extracts the request number part of this ID.
 
constexpr message_id with_high_priority () const noexcept
 Returns the same ID but high message priority. More...
 
constexpr message_id with_normal_priority () const noexcept
 Returns the same ID with normal message priority. More...
 
constexpr uint64_t integer_value () const noexcept
 Returns the "raw bytes" for this ID.
 
constexpr int64_t compare (const message_id &other) const noexcept
 Returns a negative value if *this < other, zero if *this == other, and a positive value otherwise.
 
void mark_as_answered () noexcept
 Sets the flag for marking an incoming message as answered.
 
message_idoperator++ () noexcept
 

Static Public Attributes

static constexpr uint64_t response_flag_mask = 0x8000000000000000
 The first bit flags response messages.
 
static constexpr uint64_t answered_flag_mask = 0x4000000000000000
 The second bit flags whether the actor already responded.
 
static constexpr uint64_t category_flag_mask = 0x3000000000000000
 
static constexpr uint64_t request_id_mask = 0x0FFFFFFFFFFFFFFF
 The trailing 60 bits are used for the actual ID.
 
static constexpr uint64_t urgent_message_category = 0
 Identifies one-to-one messages with high priority.
 
static constexpr uint64_t normal_message_category = 1
 Identifies one-to-one messages with normal priority.
 
static constexpr uint64_t upstream_message_category = 2
 Identifies stream messages that flow upstream, e.g., upstream_msg::ack_batch.
 
static constexpr uint64_t downstream_message_category = 3
 Identifies stream messages that flow downstream, e.g., downstream_msg::batch.
 
static constexpr uint64_t category_offset = 60
 Number of bits trailing the category.
 
static constexpr uint64_t default_async_value = 0x1000000000000000
 Default value for asynchronous messages with normal message category.
 

Friends

template<class Inspector >
Inspector::result_type inspect (Inspector &f, message_id &x)
 

Related Functions

(Note that these are not member functions.)

constexpr message_id make_message_id (normal_message_priority_constant, uint64_t value)
 Generates a message_id with given integer value.
 
constexpr message_id make_message_id (high_message_priority_constant, uint64_t value)
 Generates a message_id with given integer value.
 
template<message_priority P = message_priority::normal>
constexpr message_id make_message_id (uint64_t value=0)
 Generates a message_id with given integer value.
 
constexpr message_id make_message_id (message_priority p)
 Generates a message_id with given priority.
 

Detailed Description

Bundles various flags along with an optional request ID.

Member Function Documentation

◆ with_high_priority()

constexpr message_id caf::message_id::with_high_priority ( ) const
constexprnoexcept

Returns the same ID but high message priority.

Precondition
!is_stream_message()

◆ with_normal_priority()

constexpr message_id caf::message_id::with_normal_priority ( ) const
constexprnoexcept

Returns the same ID with normal message priority.

Precondition
!is_stream_message()

The documentation for this class was generated from the following file: