eclipse-cyclonedds / cyclonedds-cxx

Other
96 stars 75 forks source link

Clean up the C++ code to read/take samples from a DataReader #434

Closed e-hndrks closed 1 year ago

e-hndrks commented 1 year ago

Clean up the C++ code to read/take samples from a DataReader by delegating them to the new dds_read/take_with_collector calls added to the C-API.

The old code base was using some dirty tricks to peek into the contents of the reader cache in order to allocate matching C++ resources, prior to the invocation of the regular dds_read/take calls of the underlying C-API. In order for the contents of the reader cache not to change in between the peek and the actual consumption of the data, the readercache lock would not be released by the peek operation and not be claimed by the dds_read/take operation (upon passing it a special value for the max_samples parameter). However, such a dirty trick goes against many coding conventions, and for that purpose a more flexible set of data accessor operations have been added as part of https://github.com/eclipse-cyclonedds/cyclonedds/pull/1744.