RTI Connext C API
Version 5.1.0
|
<<interface>> Abstract base class for all Listener interfaces. More...
Data Fields | |
void * | listener_data |
A place for listener implementors to keep a pointer to data that may be needed by their listener. | |
<<interface>> Abstract base class for all Listener interfaces.
All the supported kinds of concrete DDS_Listener interfaces (one per concrete DDS_Entity type) derive from this root and add functions whose prototype depends on the concrete Listener.
Listeners provide a way for RTI Connext to asynchronously alert the application when there are relevant status changes.
Almost every application will have to implement listener interfaces.
Each dedicated listener presents a list of operations that correspond to the relevant communication status changes to which an application may respond.
The same DDS_Listener instance may be shared among multiple entities if you so desire. Consequently, the provided parameter contains a reference to the concerned DDS_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_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_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_DataReader objects by calling DDS_Subscriber_get_datareaders on the related DDS_Subscriber and then get the data by calling FooDataReader_read or FooDataReader_take on the returned DDS_DataReader objects), or it wants to treat each DDS_DataReader independently and it may choose the second option (and then get the data by calling FooDataReader_read or FooDataReader_take on the related DDS_DataReader).
Note that if DDS_SubscriberListener::on_data_on_readers is called, RTI Connext will not try to call DDS_DataReaderListener::on_data_available. However, an application can force a call to the DDS_DataReader objects that have data by calling DDS_Subscriber_notify_datareaders.
The operations that are allowed in DDS_Listener callbacks depend on the DDS_ExclusiveAreaQosPolicy QoS policy of the DDS_Entity to which the DDS_Listener is attached – or in the case of a DDS_DataWriter of DDS_DataReader listener, on the DDS_ExclusiveAreaQosPolicy QoS of the parent DDS_Publisher or DDS_Subscriber. For instance, the DDS_ExclusiveAreaQosPolicy settings of a DDS_Subscriber will determine which operations are allowed within the callbacks of the listeners associated with all the DataReaders created through that DDS_Subscriber.
Note: these restrictions do not apply to builtin topic listener callbacks.
Regardless of whether DDS_ExclusiveAreaQosPolicy::use_shared_exclusive_area is set to DDS_BOOLEAN_TRUE or DDS_BOOLEAN_FALSE, the following operations are not allowed:
An attempt to call a disallowed function from within a callback will result in DDS_RETCODE_ILLEGAL_OPERATION.
If DDS_ExclusiveAreaQosPolicy::use_shared_exclusive_area is set to DDS_BOOLEAN_FALSE, the setting which allows more concurrency among RTI Connext threads, the following are not allowed:
An attempt to call a disallowed function from within a callback will result in DDS_RETCODE_ILLEGAL_OPERATION.
The above limitations can be lifted by setting DDS_ExclusiveAreaQosPolicy::use_shared_exclusive_area to DDS_BOOLEAN_TRUE on the DDS_Publisher or DDS_Subscriber (or on the DDS_Publisher/ DDS_Subscriber of the DDS_DataWriter/DDS_DataReader) to which the listener is attached. However, the application will pay the cost of reduced concurrency between the affected publishers and subscribers.
void* DDS_Listener::listener_data |
A place for listener implementors to keep a pointer to data that may be needed by their listener.