Skip to content

Commit

Permalink
Process received samples only if reader enabled (#115)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Lopez Fernandez <[email protected]>
  • Loading branch information
juanlofer-eprosima authored Jun 4, 2024
1 parent c8fa514 commit ef2e6c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ void InternalReader::simulate_data_reception(
// Even if disabled, the data will be stored
data_to_send_.push(std::move(data));

// Call on data available callback
// NOTE: Track should be already created (lambda set), otherwise data will not be processed until reader is enabled
on_data_available_();
if (enabled_)
{
// Call on data available callback
// NOTE: Track should be already created (lambda set), otherwise data will not be processed until reader is enabled
on_data_available_();
}
}

utils::ReturnCode InternalReader::take_nts_(
Expand Down
14 changes: 7 additions & 7 deletions ddspipe_participants/src/cpp/reader/dds/CommonReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ void CommonReader::on_data_available(
// and the number of messages received will be slightly inaccurate.
monitor_msg_rx(topic_, participant_id_);

on_data_available_();
if (enabled_)
{
on_data_available_();
}
}

void CommonReader::on_sample_lost(
Expand Down Expand Up @@ -216,12 +219,9 @@ utils::ReturnCode CommonReader::take_nts_(

void CommonReader::enable_nts_() noexcept
{
// If the topic is reliable, the reader will keep the samples received when it was disabled.
// However, if the topic is best_effort, the reader will discard the samples received when it was disabled.
if (topic_.topic_qos.is_reliable())
{
on_data_available_();
}
// Notify messages reception in case any were received while disabled
// NOTE: unlike in the RTPS case, samples received while disabled will be processed even if the topic is best_effort
on_data_available_();
}

fastdds::dds::SubscriberQos CommonReader::reckon_subscriber_qos_() const
Expand Down

0 comments on commit ef2e6c1

Please sign in to comment.