You are here: Part 2: Core Concepts > Sending Data > DataWriters > Writing Coherent Sets of DDS Data Samples

Writing Coherent Sets of DDS Data Samples

A publishing application can request that a set of DDS data-sample changes be propagated in such a way that they are interpreted at the receivers' side as a cohesive set of modifications. In this case, the receiver will only be able to access the data after all the modifications in the set are available at the subscribing end.

This is useful in cases where the values are inter-related. For example, suppose you have two data-instances representing the ‘altitude’ and ‘velocity vector’ of the same aircraft. If both are changed, it may be important to ensure that reader see both together (otherwise, it may erroneously interpret that the aircraft is on a collision course).

To use this mechanism in C, Traditional C++, Java and .NET:

  1. Call the Publisher’s begin_coherent_changes() operation to indicate the start a coherent set.
  2. For each DDS sample in the coherent set: call the FooDataWriter’s write() operation.
  3. Call the Publisher’s end_coherent_changes() operation to terminate the set.

In the Modern C++ API:

  1. Instantiate a dds::pub::CoherentSet passing a publisher to the constructor
  2. For each DDS sample in the coherent set call dds::pub::DataWriter<Foo>::write().
  3. Let the dds::pub::CoherentSet destructor terminate the set or explicitly call dds::pub::CoherentSet::end()

Calls to begin_coherent_changes() and end_coherent_changes() can be nested.

See also: the coherent_access field in the PRESENTATION QosPolicy.

© 2016 RTI