RTI Connext Modern C++ API Version 7.2.0
dds::core::policy::Lifespan Class Reference

Specifies how long the data written by a dds::pub::DataWriter is considered valid. More...

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

Public Member Functions

 Lifespan ()
 Creates the default policy with an infinite lifespan. More...
 
 Lifespan (const dds::core::Duration &d)
 Creates a policy with the specified lifespan duration. More...
 
Lifespanduration (const dds::core::Duration &d)
 Sets the maximum duration for which the data is valid. More...
 
const dds::core::Duration duration () const
 Getter (see setter with the same name) More...
 

Detailed Description

Specifies how long the data written by a dds::pub::DataWriter is considered valid.

Each data sample written by the dds::pub::DataWriter has an associated expiration time beyond which the data should not be delivered to any application. Once the sample expires, the data will be removed from the dds::sub::DataReader caches as well as from the transient and persistent information caches.

The expiration time of each sample from the dds::pub::DataWriter's cache is computed by adding the duration specified by this QoS policy to the time when the sample is added to the dds::pub::DataWriter's cache. This timestamp is not necessarily equal to the sample's source timestamp that can be provided by the user using the dds::pub::DataWriter::write(const T&,const dds::core::Time&) or dds::pub::DataWriter::write(const T&,rti::pub::WriteParams&) API.

The expiration time of each sample from the dds::sub::DataReader's cache is computed by adding the duration to the reception timestamp.

See also
dds::pub::DataWriter::write()
dds::pub::DataWriter::write(const T&,const dds::core::Time&)
Entity:
dds::topic::Topic, dds::pub::DataWriter
Properties:
RxO = N/A
Changeable = YES

Usage

The Lifespan QoS policy can be used to control how much data is stored by RTI Connext. Even if it is configured to store "all" of the data sent or received for a topic (see dds::core::policy::History), the total amount of data it stores may be limited by this QoS policy.

You may also use this QoS policy to ensure that applications do not receive or act on data, commands or messages that are too old and have 'expired.'

To avoid inconsistencies, multiple writers of the same instance should have the same lifespan.

See also
dds::sub::SampleInfo::source_timestamp
dds::sub::SampleInfo::reception_timestamp

Constructor & Destructor Documentation

◆ Lifespan() [1/2]

dds::core::policy::Lifespan::Lifespan ( )
inline

Creates the default policy with an infinite lifespan.

◆ Lifespan() [2/2]

dds::core::policy::Lifespan::Lifespan ( const dds::core::Duration d)
inlineexplicit

Creates a policy with the specified lifespan duration.

Member Function Documentation

◆ duration() [1/2]

Lifespan & dds::core::policy::Lifespan::duration ( const dds::core::Duration d)
inline

Sets the maximum duration for which the data is valid.

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

[range] [1 nanosec, 1 year] or dds::core::Duration::infinite()

◆ duration() [2/2]

const dds::core::Duration dds::core::policy::Lifespan::duration ( ) const
inline

Getter (see setter with the same name)