how to keep pointer on the Data Writer ?

2 posts / 0 new
Last post
Offline
Joined: 12/19/2018
Posts: 2
how to keep pointer on the Data Writer ?

I have some class that hold pointer on the data writer. 

On my init function i fine the data writer by name - and i set the pointer to this data writer. 

Now, when i try to use this pointer -- i get exception that the writer is close. 

when i check the address value i see that its valid address and not null. 

what to do ? 

( code is modern C++ ) 

Offline
Joined: 10/22/2018
Posts: 3

Hi Yanshof,

Could you share the relevant snippets of code?

One thing that comes to mind is that it might be necessary to call  retain() on the DataWriter.
Explained here https://community.rti.com/static/documentation/connext-dds/current/doc/api/connext_dds/api_cpp2/group__DDSCpp2Conventions.html#a_st_ref_type,
the DataWriter entity may be being destroyed if there are no references to it.

If you do use DataWriter.retain(), you will need to call  DataWriter.close() when you want to destroy it (as it will no longer be automatically destroyed).

Sam