RTI Connext Modern C++ API  Version 5.3.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rti::core::policy::Batch Class Reference

<<extension>> Allows a dds::pub::DataWriter to batch multiple samples into a single network packet to increase throughput. More...

#include <rti/core/policy/CorePolicy.hpp>

Public Member Functions

 Batch ()
 Creates the default policy (batching is disabled)
 
Batchenable (bool the_enable)
 Enables or disables batching.
 
bool enable () const
 Returns whether batching is enabled or not.
 
Batchmax_data_bytes (int32_t the_max_data_bytes)
 Sets the maximum cumulative length of all serialized samples in a batch.
 
int32_t max_data_bytes () const
 Getter (see setter with the same name)
 
Batchmax_samples (int32_t the_max_samples)
 Sets the maximum number of samples in a batch.
 
int32_t max_samples () const
 Getter (see setter with the same name)
 
Batchmax_flush_delay (const dds::core::Duration &the_max_flush_delay)
 Sets the maximum delay after which a batch is flushed.
 
dds::core::Duration max_flush_delay () const
 Getter (see setter with the same name)
 
Batchsource_timestamp_resolution (const dds::core::Duration &the_source_timestamp_resolution)
 Sets the timestamp resolution of the samples in a batch.
 
dds::core::Duration source_timestamp_resolution () const
 Getter (see setter with the same name)
 
Batchthread_safe_write (bool the_thread_safe_write)
 Indicates if the write operation needs to be thread-safe.
 
bool thread_safe_write () const
 Getter (see setter with the same name)
 

Static Public Member Functions

static Batch Enabled ()
 Returns an instance that enables batching with the default max_samples() and max_data_bytes().
 
static Batch Disabled ()
 Returns an instance that disables batching.
 
static Batch EnabledWithMaxDataBytes (int32_t the_max_bytes)
 Returns an instance that enables batching with max_data_bytes()
 
static Batch EnabledWithMaxSamples (int32_t the_max_samples)
 Returns an instance that enables batching with max_samples()
 

Detailed Description

<<extension>> Allows a dds::pub::DataWriter to batch multiple samples into a single network packet to increase throughput.

This QoS policy configures the ability of the middleware to collect multiple user data samples to be sent in a single network packet, to take advantage of the efficiency of sending larger packets and thus increase effective throughput.

This QoS policy can be used to dramatically increase effective throughput for small data samples. Usually, throughput for small samples (size < 2048 bytes) is limited by CPU capacity and not by network bandwidth. Batching many smaller samples to be sent in a single large packet will increase network utilization, and thus throughput, in terms of samples per second.

Entity:
dds::pub::DataWriter
Properties:
RxO = NO
Changeable = UNTIL ENABLE

Constructor & Destructor Documentation

rti::core::policy::Batch::Batch ( )
inline

Creates the default policy (batching is disabled)

Member Function Documentation

static Batch rti::core::policy::Batch::Enabled ( )
inlinestatic

Returns an instance that enables batching with the default max_samples() and max_data_bytes().

static Batch rti::core::policy::Batch::Disabled ( )
inlinestatic

Returns an instance that disables batching.

static Batch rti::core::policy::Batch::EnabledWithMaxDataBytes ( int32_t  the_max_bytes)
inlinestatic

Returns an instance that enables batching with max_data_bytes()

For example:

using namespace rti::core::policy;
writer_qos << Batch::EnabledWithMaxDataBytes(2048);
static Batch rti::core::policy::Batch::EnabledWithMaxSamples ( int32_t  the_max_samples)
inlinestatic

Returns an instance that enables batching with max_samples()

Batch& rti::core::policy::Batch::enable ( bool  the_enable)

Enables or disables batching.

bool rti::core::policy::Batch::enable ( ) const

Returns whether batching is enabled or not.

Batch& rti::core::policy::Batch::max_data_bytes ( int32_t  the_max_data_bytes)

Sets the maximum cumulative length of all serialized samples in a batch.

A batch is flushed automatically when this maximum is reached.

max_data_bytes does not include the meta data associated with the batch samples. Each sample has at least 8 bytes of meta data containing information such as the timestamp and sequence number. The meta data can be as large as 52 bytes for keyed topics and 20 bytes for unkeyed topics.

Note: Batches must contain whole samples. If a new batch is started and its initial sample causes the serialized size to exceed max_data_bytes, RTI Connext will send the sample in a single batch.

[default] 1024

[range] [1,dds::core::LENGTH_UNLIMITED]

Consistency

The setting of rti::core::policy::Batch::max_data_bytes must be consistent with rti::core::policy::Batch::max_samples. For these two values to be consistent, they cannot be both dds::core::LENGTH_UNLIMITED.

int32_t rti::core::policy::Batch::max_data_bytes ( ) const

Getter (see setter with the same name)

Batch& rti::core::policy::Batch::max_samples ( int32_t  the_max_samples)

Sets the maximum number of samples in a batch.

A batch is flushed automatically when this maximum is reached.

[default] dds::core::LENGTH_UNLIMITED

[range] [1,dds::core::LENGTH_UNLIMITED]

Consistency

The setting of rti::core::policy::Batch::max_samples must be consistent with rti::core::policy::Batch::max_data_bytes. For these two values to be consistent, they cannot be both dds::core::LENGTH_UNLIMITED.

int32_t rti::core::policy::Batch::max_samples ( ) const

Getter (see setter with the same name)

Batch& rti::core::policy::Batch::max_flush_delay ( const dds::core::Duration the_max_flush_delay)

Sets the maximum delay after which a batch is flushed.

A batch is flushed automatically after the delay specified by this parameter.

The delay is measured from the time the first sample in the batch is written by the application.

[default] dds::core::Duration::infinite()

[range] [0,dds::core::Duration::infinite()]

Consistency

The setting of rti::core::policy::Batch::max_flush_delay must be consistent with rti::core::policy::AsynchronousPublisher::disable_asynchronous_batch and rti::core::policy::Batch::thread_safe_write. If the delay is different than dds::core::Duration::infinite(), rti::core::policy::AsynchronousPublisher::disable_asynchronous_batch must be set to false and rti::core::policy::Batch::thread_safe_write must be set to true.

dds::core::Duration rti::core::policy::Batch::max_flush_delay ( ) const

Getter (see setter with the same name)

Batch& rti::core::policy::Batch::source_timestamp_resolution ( const dds::core::Duration the_source_timestamp_resolution)

Sets the timestamp resolution of the samples in a batch.

The value of this field determines how the source timestamp is associated with the samples in a batch.

A sample written with timestamp 't' inherits the source timestamp 't2' associated with the previous sample unless ('t' - 't2') > source_timestamp_resolution.

If source_timestamp_resolution is set to dds::core::Duration::infinite(), every sample in the batch will share the source timestamp associated with the first sample.

If source_timestamp_resolution is set to zero, every sample in the batch will contain its own source timestamp corresponding to the moment when the sample was written.

The performance of the batching process is better when source_timestamp_resolution is set to dds::core::Duration::infinite().

[default] dds::core::Duration::infinite()

[range] [0,dds::core::Duration::infinite()]

Consistency

The setting of rti::core::policy::Batch::source_timestamp_resolution must be consistent with rti::core::policy::Batch::thread_safe_write. If rti::core::policy::Batch::thread_safe_write is set to false, rti::core::policy::Batch::source_timestamp_resolution must be set to dds::core::Duration::infinite().

dds::core::Duration rti::core::policy::Batch::source_timestamp_resolution ( ) const

Getter (see setter with the same name)

Batch& rti::core::policy::Batch::thread_safe_write ( bool  the_thread_safe_write)

Indicates if the write operation needs to be thread-safe.

If this parameter is set to true, multiple threads can call write on the dds::pub::DataWriter concurrently.

[default] true

Consistency

The setting of rti::core::policy::Batch::thread_safe_write must be consistent with rti::core::policy::Batch::source_timestamp_resolution. If rti::core::policy::Batch::thread_safe_write is set to false, rti::core::policy::Batch::source_timestamp_resolution must be set to dds::core::Duration::infinite().

bool rti::core::policy::Batch::thread_safe_write ( ) const

Getter (see setter with the same name)


RTI Connext Modern C++ API Version 5.3.0 Copyright © Sun Jun 25 2017 Real-Time Innovations, Inc