You are here: Part 2: Core Concepts > Working with DDS Domains > DomainParticipants > Deleting DomainParticipants

Deleting DomainParticipants

If the application is no longer interested in communicating in a certain DDS domain, the DomainParticipant can be deleted. A DomainParticipant can be deleted only after all the Entities that were created by the DomainParticipant have been deleted (see Deleting Contained Entities).

To delete a DomainParticipant:

You must first delete all Entities (Publishers, Subscribers, ContentFilteredTopics, and Topics) that were created with the DomainParticipant. Use the DomainParticipant’s delete_<entity>() operations to delete them one at a time, or use the delete_contained_entities() operation (Deleting Contained Entities) to delete them all at the same time.

DDS_ReturnCode_t delete_publisher  (DDSPublisher  *p) 
DDS_ReturnCode_t delete_subscriber (DDSSubscriber *s) 
DDS_ReturnCode_t delete_contentfilteredtopic 
(DDSContentFilteredTopic *a_contentfilteredtopic) DDS_ReturnCode_t delete_topic (DDSTopic *topic)

Delete the DomainParticipant by using the DomainParticipantFactory’s delete_participant() operation.

DDS_ReturnCode_t delete_participant 
(DDSDomainParticipant *a_participant)

Note: A DomainParticipant cannot be deleted within its Listener callback, see Restricted Operations in Listener Callbacks.

After a DomainParticipant has been deleted, all of the participant’s internal Connext DDS threads and allocated memory will have been deleted. You should delete the DomainParticipantListener only after the DomainParticipant itself has been deleted.

Note: In the Modern C++ API, Entities are automatically destroyed.

© 2016 RTI