| 506 | } |
| 507 | |
| 508 | DDS::ReturnCode_t |
| 509 | WriteDataContainer::remove_instance(PublicationInstance_rch instance, |
| 510 | Message_Block_Ptr& registered_sample, |
| 511 | bool dup_registered_sample) |
| 512 | { |
| 513 | if (dup_registered_sample) { |
| 514 | // The registered_sample is shallow copied. |
| 515 | registered_sample.reset(instance->registered_sample_->duplicate()); |
| 516 | } |
| 517 | |
| 518 | // Note: The DDS specification is unclear as to if samples in the process |
| 519 | // of being sent should be removed or not. |
| 520 | // The advantage of calling remove_sample() on them is that the |
| 521 | // cached allocator memory for them is freed. The disadvantage |
| 522 | // is that the slow reader may see multiple disposes without |
| 523 | // any write sample between them and hence not temporarily move into the |
| 524 | // Alive state. |
| 525 | // We have chosen to NOT remove the sending samples. |
| 526 | InstanceDataSampleList& instance_list = instance->samples_; |
| 527 | |
| 528 | while (instance_list.size() > 0) { |
| 529 | bool released = false; |
| 530 | const DDS::ReturnCode_t ret = remove_oldest_sample(instance_list, released); |
| 531 | if (ret != DDS::RETCODE_OK) { |
| 532 | return ret; |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | cancel_deadline(instance); |
| 537 | |
| 538 | return DDS::RETCODE_OK; |
| 539 | } |
| 540 | |
| 541 | DDS::ReturnCode_t |
| 542 | WriteDataContainer::num_samples(DDS::InstanceHandle_t handle, |