Skip to content

Commit

Permalink
Refs #21121: Revision - minor changes
Browse files Browse the repository at this point in the history
Signed-off-by: cferreiragonz <[email protected]>
  • Loading branch information
cferreiragonz committed Jun 6, 2024
1 parent 8124363 commit 2603502
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 30 deletions.
12 changes: 6 additions & 6 deletions include/fastdds/rtps/common/SerializedPayload.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@ struct FASTDDS_EXPORTED_API SerializedPayload_t

~SerializedPayload_t()
{
if (payload_owner != nullptr)
{
payload_owner->release_payload(*this);
}
assert(payload_owner == nullptr);

this->empty();
}

Expand Down Expand Up @@ -162,6 +156,12 @@ struct FASTDDS_EXPORTED_API SerializedPayload_t
//! Empty the payload
void empty()
{
if (payload_owner != nullptr)
{
payload_owner->release_payload(*this);
}
assert(payload_owner == nullptr);

length = 0;
encapsulation = CDR_BE;
max_size = 0;
Expand Down
3 changes: 0 additions & 3 deletions include/fastdds/rtps/history/IPayloadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ class IPayloadPool
* the payload (after all readers have been informed of the received data), method @c release_payload will be
* called to indicate that the reception thread is not using the payload anymore.
*
* @warning @c data_owner contained in @c data can only be changed from @c nullptr to @c this. If a value
* different from @c nullptr is received it should be left unchanged.
*
* @warning @c data fields can only be changed when @c payload_owner contained in @c data is @c nullptr. If a
* value different from @c nullptr is received all fields in @c data should be left unchanged.
*
Expand Down
8 changes: 4 additions & 4 deletions src/cpp/fastdds/publisher/DataWriterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ ReturnCode_t DataWriterImpl::loan_sample(
if (!add_loan(sample, payload))
{
sample = nullptr;
return_payload_to_pool(payload);
payload_pool_->release_payload(payload);
return RETCODE_OUT_OF_RESOURCES;
}

Expand All @@ -557,7 +557,7 @@ ReturnCode_t DataWriterImpl::loan_sample(
if (!type_->construct_sample(sample))
{
check_and_remove_loan(sample, payload);
return_payload_to_pool(payload);
payload_pool_->release_payload(payload);
sample = nullptr;
return RETCODE_UNSUPPORTED;
}
Expand Down Expand Up @@ -592,7 +592,7 @@ ReturnCode_t DataWriterImpl::discard_loan(
}

// Return payload to pool
return_payload_to_pool(payload);
payload_pool_->release_payload(payload);
sample = nullptr;

return RETCODE_OK;
Expand Down Expand Up @@ -987,7 +987,7 @@ ReturnCode_t DataWriterImpl::perform_create_new_change(
if ((ALIVE == change_kind) && !type_->serialize(data, &payload, data_representation_))
{
EPROSIMA_LOG_WARNING(DATA_WRITER, "Data serialization returned false");
return_payload_to_pool(payload);
payload_pool_->release_payload(payload);
return RETCODE_ERROR;
}
}
Expand Down
16 changes: 1 addition & 15 deletions src/cpp/fastdds/publisher/DataWriterImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -671,34 +671,20 @@ class DataWriterImpl : protected rtps::IReaderDataFilter
const SizeFunctor& size_getter,
SerializedPayload_t& payload)
{
CacheChange_t change;
if (!payload_pool_)
{
return false;
}

uint32_t size = fixed_payload_size_ ? fixed_payload_size_ : size_getter();
if (!payload_pool_->get_payload(size, change.serializedPayload))
if (!payload_pool_->get_payload(size, payload))
{
return false;
}

payload = change.serializedPayload;
change.serializedPayload.data = nullptr;
change.serializedPayload.payload_owner = nullptr;
return true;
}

void return_payload_to_pool(
SerializedPayload_t& payload)
{
CacheChange_t change;
change.serializedPayload = payload;
payload.data = nullptr;
payload.payload_owner = nullptr;
payload_pool_->release_payload(change.serializedPayload);
}

bool add_loan(
void* data,
SerializedPayload_t& payload);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ struct SampleLoanManager
if (item->num_refs == 0)
{
item->payload.payload_owner->release_payload(item->payload);
item->payload.data = nullptr;
item->payload.payload_owner = nullptr;
assert(item->payload.data == nullptr);
assert(item->payload.payload_owner == nullptr);

item = free_loans_.push_back(*item);
assert(nullptr != item);
Expand Down

0 comments on commit 2603502

Please sign in to comment.