STAPL API Reference          
Overview   Containers   Algorithms   Views   Skeletons   Run-Time System
Modules     Classes    
List of all members | Classes | Public Member Functions | Static Public Member Functions | Public Types | Public Attributes

Communication buffer. More...

Classes

struct  header_type
 Message header. More...
 

Public Member Functions

void reset (void) noexcept
 Resets this message for reuse.
 
message_handle const & handle (void) const noexcept
 
message_handlehandle (void) noexcept
 
char * data (void) noexcept
 Returns a pointer to the internal buffer. More...
 
const char * data (void) const noexcept
 Returns a pointer to the internal buffer. noexcept More...
 
std::size_t capacity (void) const noexcept
 Returns the capacity of the internal buffer in bytes.
 
std::size_t size (void) const noexcept
 Returns the size of the internal buffer in bytes.
 
bool is_long (void) const noexcept
 Returns true if the size is bigger than the default capacity.
 
header_type const & header (void) const noexcept
 
header_typeheader (void) noexcept
 
header::type type (void) const noexcept
 Returns the type of the message.
 
void retarget (const header::type t) noexcept
 Changes the type of the message.
 
bool body_empty (void) const noexcept
 Returns true if there is no message body.
 
template<typename T >
T const & fix_payload_offset (void) noexcept
 Updates the offset to the payload and returns the extended header.
 
template<typename T >
T const & get_extended_header (void) const noexcept
 Returns the extended header.
 
payload_range_type payload (void) noexcept
 Returns a range over the payload.
 
std::size_t available_space (void) const noexcept
 Available space for the payload in bytes.
 
void * reserve (const std::size_t n) noexcept
 Returns a pointer to n bytes reserved in the internal buffer.
 
void * try_reserve (const std::size_t n) noexcept
 Returns a pointer to n bytes reserved in the internal buffer or nullptr if there is not enough space.
 
bool is_forwarded (void) const noexcept
 Returns true if this message has been forwarded.
 
void mark_forwarded (void) noexcept
 Marks that this message has been forwarded.
 
message_ptr clone (void) const
 Creates an identical copy of this message.
 
void add_ref (long count=1, std::memory_order order=std::memory_order_relaxed) noexcept
 Increases the reference count by count.
 
long remove_ref (long count=1, std::memory_order order=std::memory_order_relaxed) noexcept
 Decreases the reference count by count. More...
 
bool release (std::memory_order order=std::memory_order_relaxed) noexcept
 Decreases the reference count, destroying the object if it reached 0. More...
 
long use_count (std::memory_order order=std::memory_order_relaxed) const noexcept
 
bool unique (std::memory_order order=std::memory_order_relaxed) const noexcept
 

Static Public Member Functions

static void initialize (option const &opts, const unsigned int nppn)
 Initializes the memory for allocating message objects. More...
 
static void finalize (void)
 Finalizes the memory for allocating message objects.
 
static std::size_t default_capacity (void) noexcept
 Returns the default capacity of the internal buffer (header and body) in bytes.
 
static std::size_t header_size (void) noexcept
 Returns the size of the header in bytes.
 
static void set_default_body_capacity (const std::size_t)
 Sets the default capacity for the body in bytes.
 
static std::size_t default_body_capacity (void) noexcept
 Returns the default capacity for the body in bytes.
 
static messageconstruct (void)
 Constructs a message of default capacity.
 
static messageconstruct (const std::size_t n, const bool exact_size)
 Constructs a message of with capacity of n bytes. More...
 
static void destroy (message *msg)
 Destroys msg.
 
static message_ptr create (const std::size_t n, const bool exact_size=true)
 Constructs a message that can store at least n bytes. More...
 
static message_ptr create (const header::type h, const std::size_t n, const bool exact_size=true)
 Constructs a message that can store at least n bytes. More...
 
template<typename ExtendedHeader >
static message_ptr create (const header::type h, const std::size_t n, ExtendedHeader &&exh, const bool exact_size=true)
 Constructs a message that can store at least n bytes. More...
 

Public Types

using payload_range_type = boost::iterator_range< char * >
 
using slist_hook_type = boost::intrusive::slist_member_hook<>
 

Public Attributes

slist_hook_type slist_hook
 Hook for boost::intrusive::slist.
 

Detailed Description

Communication buffer.

A message consists of a standard, fixed header that gives information about the size and the type of the message and the message body. The body contains data relevant to communication, such as additional headers and/or payload.

Member Function Documentation

◆ initialize()

void stapl::runtime::message::initialize ( option const &  opts,
const unsigned int  nppn 
)
static

Initializes the memory for allocating message objects.

The following options are supported through opts:

  1. STAPL_RUNTIME_MSG_SIZE to change the default capacity.
  2. STAPL_RUNTIME_MSG_POOL_DISABLE to disable pool message allocation.
  3. STAPL_RUNTIME_MSG_POOL_MIN_NUM Minimum number of allocated message objects when pool allocation is enabled.
  4. STAPL_RUNTIME_MSG_MAX_MEM the maximum fraction of memory to use when pool allocation is enabled.
Parameters
optsOptions to pass for initialization.
nppnNumber of processes per node.

◆ construct()

message * stapl::runtime::message::construct ( const std::size_t  n,
const bool  exact_size 
)
static

Constructs a message of with capacity of n bytes.

Parameters
nRequested capacity in bytes.
exact_sizetrue if there is no benefit to providing extra capacity.

◆ create() [1/3]

static message_ptr stapl::runtime::message::create ( const std::size_t  n,
const bool  exact_size = true 
)
static

Constructs a message that can store at least n bytes.

Parameters
nRequested capacity in bytes.
exact_sizetrue if there is no benefit to providing extra capacity.

◆ create() [2/3]

static message_ptr stapl::runtime::message::create ( const header::type  h,
const std::size_t  n,
const bool  exact_size = true 
)
static

Constructs a message that can store at least n bytes.

Parameters
hMessage type.
nRequested capacity in bytes.
exact_sizetrue if there is no benefit to providing extra capacity.

◆ create() [3/3]

template<typename ExtendedHeader >
static message_ptr stapl::runtime::message::create ( const header::type  h,
const std::size_t  n,
ExtendedHeader &&  exh,
const bool  exact_size = true 
)
static

Constructs a message that can store at least n bytes.

Parameters
hMessage type.
nRequested capacity in bytes.
exhExtended header.
exact_sizetrue if there is no benefit to providing extra capacity.

◆ data() [1/2]

char * stapl::runtime::message::data ( void  )
noexcept

Returns a pointer to the internal buffer.

Flexible array members are not supported in C++. This function returns a pointer past the end of this message object which is properly sized and aligned to store requests in it.

◆ data() [2/2]

char const * stapl::runtime::message::data ( void  ) const
noexcept

Returns a pointer to the internal buffer. noexcept

Flexible array members are not supported in C++. This function returns a pointer past the end of this message object which is properly sized and aligned to store requests in it. noexcept

◆ remove_ref()

long stapl::runtime::ref_counted< message , message_delete >::remove_ref ( long  count = 1,
std::memory_order  order = std::memory_order_relaxed 
)
noexceptinherited

Decreases the reference count by count.

Returns
The new reference count.

◆ release()

bool stapl::runtime::ref_counted< message , message_delete >::release ( std::memory_order  order = std::memory_order_relaxed)
noexceptinherited

Decreases the reference count, destroying the object if it reached 0.

Warning
If release() returns true, then the object has been destroyed.
Returns
true if the object was destroyed, otherwise false.

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