RTI Connext Modern C++ API
Version 5.2.0
|
Entity listeners. More...
#include <dds/dds.hpp>
Entity listeners.
Listeners provide a way for RTI Connext to asynchronously alert the application when there are relevant status changes.
Each dedicated listener presents a list of operations that correspond to the relevant communication status changes to which an application may respond.
The same Listener instance may be shared among multiple entities if you so desire. Consequently, the provided parameter contains a reference to the concerned dds::core::Entity.
The general mapping between the plain communication statuses (see Status Kinds) and the listeners' operations is as follows:
on_<communication_status>
(), which takes a parameter of type <communication_status>
as listed in Status Kinds. on_<communication_status>
is available on the relevant dds::core::Entity as well as those that embed it, as expressed in the following figure: This behavior allows the application to set a default behavior (e.g., in the listener associated with the dds::domain::DomainParticipant) and to set dedicated behaviors only where needed.
The two statuses related to data arrival are treated slightly differently. Since they constitute the core purpose of the Data Distribution Service, there is no need to provide a default mechanism (as is done for the plain communication statuses above).
The rule is as follows. Each time the read communication status changes:
The rationale is that either the application is interested in relations among data arrivals and it must use the first option (and then get the corresponding dds::sub::DataReader objects by calling dds::sub::find on the related dds::sub::Subscriber and then get the data by calling dds::sub::DataReader::read or dds::sub::DataReader::take on the returned dds::sub::DataReader objects), or it wants to treat each dds::sub::DataReader independently and it may choose the second option (and then get the data by calling dds::sub::DataReader::read or dds::sub::DataReader::take on the related dds::sub::DataReader).
Note that if dds::sub::SubscriberListener::on_data_on_readers is called, RTI Connext will not try to call dds::sub::DataReaderListener::on_data_available. However, an application can force a call to the dds::sub::DataReader objects that have data by calling dds::sub::Subscriber::notify_datareaders.
The operations that are allowed in Listener callbacks depend on the rti::core::policy::ExclusiveArea QoS policy of the dds::core::Entity to which the Listener is attached – or in the case of a dds::pub::DataWriter of dds::sub::DataReader listener, on the rti::core::policy::ExclusiveArea QoS of the parent dds::pub::Publisher or dds::sub::Subscriber. For instance, the rti::core::policy::ExclusiveArea settings of a dds::sub::Subscriber will determine which operations are allowed within the callbacks of the listeners associated with all the DataReaders created through that dds::sub::Subscriber.
Note: these restrictions do not apply to builtin topic listener callbacks.
Regardless of whether rti::core::policy::ExclusiveArea::use_shared_exclusive_area is set to true or false, the following operations are not allowed:
An attempt to call a disallowed method from within a callback will result in dds::core::IllegalOperationError.
If rti::core::policy::ExclusiveArea::use_shared_exclusive_area is set to false, the setting which allows more concurrency among RTI Connext threads, the following are not allowed:
An attempt to call a disallowed method from within a callback will result in dds::core::IllegalOperationError.
The above limitations can be lifted by setting rti::core::policy::ExclusiveArea::use_shared_exclusive_area to true on the dds::pub::Publisher or dds::sub::Subscriber (or on the dds::pub::Publisher/ dds::sub::Subscriber of the dds::pub::DataWriter/dds::sub::DataReader) to which the listener is attached. However, the application will pay the cost of reduced concurrency between the affected publishers and subscribers.