nalchi
All Classes Files Functions Variables Typedefs Pages Concepts
shared_payload_flat.hpp File Reference

Shared payload flat API. More...

#include "nalchi/shared_payload.hpp"
#include "nalchi/export.hpp"

Go to the source code of this file.

Functions

nalchi::shared_payload nalchi_shared_payload_allocate (nalchi::shared_payload::alloc_size_t size)
 Allocates a shared payload that can be used to send some data.
 
void nalchi_shared_payload_force_deallocate (nalchi::shared_payload payload)
 Force deallocates the shared payload without sending it.
 
auto nalchi_shared_payload_size (const nalchi::shared_payload payload) -> nalchi::shared_payload::alloc_size_t
 Gets the requested allocation size of the payload.
 
auto nalchi_shared_payload_word_ceiled_size (const nalchi::shared_payload payload) -> nalchi::shared_payload::alloc_size_t
 Gets the payload size that's ceiled to bit_stream_writer::word_size, which is guaranteed to be safe to access.
 
auto nalchi_shared_payload_internal_alloc_size (const nalchi::shared_payload payload) -> nalchi::shared_payload::alloc_size_t
 Gets the actual allocated size, which includes hidden ref count & size fields.
 
bool nalchi_shared_payload_used_bit_stream (const nalchi::shared_payload payload)
 Check if this payload used bit_stream_writer to fill its content.
 

Detailed Description

Shared payload flat API.

Function Documentation

◆ nalchi_shared_payload_allocate()

nalchi::shared_payload nalchi_shared_payload_allocate ( nalchi::shared_payload::alloc_size_t size)

Allocates a shared payload that can be used to send some data.

Note
You should check if ptr is nullptr or not to see if the allocation has been successful.
Parameters
sizeSpace in bytes to allocate.
Returns
Shared payload instance that might hold allocated buffer.

◆ nalchi_shared_payload_force_deallocate()

void nalchi_shared_payload_force_deallocate ( nalchi::shared_payload payload)

Force deallocates the shared payload without sending it.

Note
If you send the payload, nalchi takes the ownership of the payload and releases it automatically.
So, you should not call this if you already sent the payload.

Calling this is only necessary when you have some exceptions in your program that prevents sending the allocated payload.
Parameters
payloadShared payload to force deallocate.

◆ nalchi_shared_payload_internal_alloc_size()

auto nalchi_shared_payload_internal_alloc_size ( const nalchi::shared_payload payload) -> nalchi::shared_payload::alloc_size_t

Gets the actual allocated size, which includes hidden ref count & size fields.

This is meant to be only used by the internal API.

Returns
Size of the allocated space in bytes.

◆ nalchi_shared_payload_size()

auto nalchi_shared_payload_size ( const nalchi::shared_payload payload) -> nalchi::shared_payload::alloc_size_t

Gets the requested allocation size of the payload.

Returns
Size of the payload in bytes.

◆ nalchi_shared_payload_used_bit_stream()

bool nalchi_shared_payload_used_bit_stream ( const nalchi::shared_payload payload)

Check if this payload used bit_stream_writer to fill its content.

If this is true, the send size will be automatically ceiled to multiple of bit_stream_reader::word_size when you send it.
This is to maintain compatibility with bit_stream_reader on the receiving side.

Returns
Whether the payload used bit_stream_writer or not.

◆ nalchi_shared_payload_word_ceiled_size()

auto nalchi_shared_payload_word_ceiled_size ( const nalchi::shared_payload payload) -> nalchi::shared_payload::alloc_size_t

Gets the payload size that's ceiled to bit_stream_writer::word_size, which is guaranteed to be safe to access.

As this size is ceiled to multiple of bit_stream_writer::word_size, it can be bigger than the requested allocation size.
This is to maintain compatibility with bit_stream_writer.

Returns
Size of the payload in bytes.