Jump to content
OpenSplice DDS Forum
Emmanuel Prunet

register_instance vs lookup_instance

Recommended Posts


I want to know the best usage of register_instance and lookup_instance on a datawriter for successive write of the same instance.

Should I do :


auto h1 = writer.register_instance(ddsData);



writer.write(ddsData, map.find(h1));





writer.write(ddsData, writer.lookup_instance(ddsData));



writer.write(ddsData, writer.register_instance(ddsData));



In I) I register the instance and save it in a map. Then, when I want to write the instance, I get the instance_handle in the map and use it in the write() call.

In II) I just register the instance. Then, when I want to write the instance, I retrieve the instance_handle with lookup_instance and use it in the write() call.

In III) I register the instance in the write() call.


If register_instance is idempotent, I think III) is what I want to do : registering the instance the first time then use the instance_handle for the write call.

But I don't know if instance handles are internally stored in a map or if I should do it myself like in I)


Share this post

Link to post
Share on other sites


When writing the same instance (i.e. key-value) repeatedly (but with different non-key field values), its fine to utilize the same handle.

The handle is a local-concept (so can't be shared between participants) and can improve performance when writing specific instances from large (key-)sets.

Note also that its not mandatory to use the register_instance, if you don't explicitly register the instance, it will be done implicitly yet costs a little time to locate the 'right instance' based on the value of the key-fields in the provided sample.

Note also that an error will be raised when the key-fields of any provided sample in a write doesn't match with the instance-handle (if provided)

Hope this helps,


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now