hpx/serialization/output_archive.hpp#

Defined in header hpx/serialization/output_archive.hpp.

See Public API for a list of names and headers that are part of the public HPX API.

namespace hpx
namespace serialization
struct output_archive : public basic_archive<output_archive>#

Public Types

using base_type = basic_archive<output_archive>#

Public Functions

template<typename Container>
inline explicit output_archive(Container &buffer, std::uint32_t const flags = 0U, std::vector<serialization_chunk> *chunks = nullptr, binary_filter *filter = nullptr, std::size_t zero_copy_serialization_threshold = 0)#
template<typename Container>
inline output_archive(Container &buffer, archive_flags flags, std::vector<serialization_chunk> *chunks = nullptr, binary_filter *filter = nullptr, std::size_t zero_copy_serialization_threshold = 0)#
inline constexpr std::size_t bytes_written() const noexcept#
inline constexpr bool is_filtered() const noexcept#
inline std::size_t get_num_chunks() const noexcept#
inline std::size_t get_zero_copy_serialization_threshold() const noexcept#
inline constexpr std::size_t current_pos() const noexcept#
inline void reset()#
inline void flush() const#
template<typename T>
inline void invoke(T const &t)#
template<typename T>
inline void invoke_impl(T const &t)#
template<typename T>
inline void save(T const &t)#
inline void save(float const f)#
inline void save(double const d)#
inline void save(long double const d)#
inline void save(char const c)#
inline void save(signed char const c)#
inline void save(unsigned char const c)#
inline void save(bool const b)#
inline void save_binary(detail::fundamental_types t, void const *address, std::size_t const count)#
inline void save_binary_chunk(detail::fundamental_types t, void const *address, std::size_t const count, chunk_memory const memory = chunk_memory::host)#

Writes count bytes at address as a zero-copy chunk, or copies them into the archive (as save_binary does) if the archive collects no chunks.

A zero-copy chunk refers to the memory instead of copying it: the memory must stay valid and unchanged until the chunks of the archive have been sent (for a parcel: until the parcel has been sent). The memory of the objects a parcel holds (its arguments and what they own) lives that long. The memory of a temporary object a serialize() function creates while it runs doesn’t: once freed (or given back to a memory pool), it may be reused before it is sent, and the receiver would get other data, without an error. Such data must be copied into the archive (save_binary), be owned by the object being serialized, or be kept alive by the parcel (see serialization::detail::preprocess_keep_alive).

Parameters:
  • t – The type of the data, checked by archives with type checking.

  • address – The data.

  • count – The number of bytes.

  • memory – Whether address refers to device memory: the chunk is marked (see serialization_chunk::is_device_memory).

Private Members

std::unique_ptr<erased_output_container> buffer_#
bool filtered_ = false#

Private Static Functions

static inline constexpr std::uint32_t make_flags(std::uint32_t const flags, std::vector<serialization_chunk> const *chunks) noexcept#

Friends

friend struct basic_archive< output_archive >