Syntalos::supports_buffer_reuse

Syntalos::supports_buffer_reuse

Syntalos::supports_buffer_reuse

More…

#include <datatypes.h>

Inherits from std::false_type

Detailed Description

template <typename T >
struct Syntalos::supports_buffer_reuse;

Opt-in trait for buffer-reuse in DataStream.

When supports_buffer_reuse::value is true, DataStream holds a single per-stream scratch object of type T and calls T::fromMemoryInto() on every received raw buffer instead of constructing a fresh T. This avoids a malloc/free round-trip for types that carry large heap-allocated payloads (e.g. Frame’s cv::Mat pixel buffer).

To opt a type in:

  1. Implement static void T::fromMemoryInto(const void*, size_t, T&) that deserializes into an existing T, reusing its internal buffers when the incoming data fits and the buffer is exclusively owned. REMEMBER TO CHECK REFCOUNT OF TARGET OBJECT BEFORE WRITING!!!
  2. Add a full specialization of supports_buffer_reuse below.

Updated on 2026-03-16 at 19:16:01 +0000