@@ -125,7 +125,7 @@ void rtps_api_example_create_entities()
125125 // RTPS_API_CONF_PARTICIPANT
126126 RTPSParticipantAttributes participant_attr;
127127 participant_attr.setName (" my_participant" );
128- // etc.
128+ // etc.
129129 // !--
130130 }
131131
@@ -151,14 +151,11 @@ void rtps_api_example_create_entities()
151151 }
152152
153153 // RTPS_API_WRITE_SAMPLE
154- // Request a change from the writer
155- CacheChange_t* change = writer->new_change ([]() -> uint32_t
156- {
157- return 255 ;
158- }, ALIVE );
159- // Write serialized data into the change
154+ // Request a change from the history
155+ CacheChange_t* change = history->create_change (255 , ALIVE );
156+ // Write serialized data into the change
160157 change->serializedPayload .length = sprintf ((char *) change->serializedPayload .data , " My example string %d" , 2 ) + 1 ;
161- // Insert change into the history. The Writer takes care of the rest.
158+ // Insert change into the history. The Writer takes care of the rest.
162159 history->add_change (change);
163160 // !--
164161}
@@ -242,9 +239,9 @@ void rtps_api_example_create_entities_with_custom_pool()
242239
243240 // A writer using the custom payload pool
244241 HistoryAttributes writer_history_attr;
245- WriterHistory* writer_history = new WriterHistory (writer_history_attr);
242+ WriterHistory* writer_history = new WriterHistory (writer_history_attr, payload_pool );
246243 WriterAttributes writer_attr;
247- RTPSWriter* writer = RTPSDomain::createRTPSWriter (participant, writer_attr, payload_pool, writer_history);
244+ RTPSWriter* writer = RTPSDomain::createRTPSWriter (participant, writer_attr, writer_history);
248245
249246 // A reader using the same instance of the custom payload pool
250247 HistoryAttributes reader_history_attr;
@@ -254,10 +251,7 @@ void rtps_api_example_create_entities_with_custom_pool()
254251
255252 // Write and Read operations work as usual, but take the Payloads from the pool.
256253 // Requesting a change to the Writer will provide one with an empty Payload taken from the pool
257- CacheChange_t* change = writer->new_change ([]() -> uint32_t
258- {
259- return 255 ;
260- }, ALIVE );
254+ CacheChange_t* change = writer_history->create_change (255 , ALIVE );
261255
262256 // Write serialized data into the change and add it to the history
263257 change->serializedPayload .length = sprintf ((char *) change->serializedPayload .data , " My example string %d" , 2 ) + 1 ;
@@ -279,12 +273,12 @@ void rtps_api_example_conf()
279273 // !--
280274
281275 // RTPS_API_HISTORY_CONF_PAYLOADMAXSIZE
282- history_attr.payloadMaxSize = 250 ;// Defaults to 500 bytes
276+ history_attr.payloadMaxSize = 250 ; // Defaults to 500 bytes
283277 // !--
284278
285279 // RTPS_API_HISTORY_CONF_RESOURCES
286- history_attr.initialReservedCaches = 250 ; // Defaults to 500
287- history_attr.maximumReservedCaches = 500 ; // Defaults to 0 = Unlimited Changes
280+ history_attr.initialReservedCaches = 250 ; // Defaults to 500
281+ history_attr.maximumReservedCaches = 500 ; // Defaults to 0 = Unlimited Changes
288282 // !--
289283}
290284
0 commit comments