Skip to content

Commit

Permalink
Refs 10497. PubSubParticipant takes data when received.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
  • Loading branch information
MiguelCompany committed Feb 17, 2021
1 parent 743a75c commit b53bfb0
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions test/blackbox/api/dds-pim/PubSubParticipant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ class PubSubParticipant

}

void on_data_available(
eprosima::fastdds::dds::DataReader* reader) override
{
TypeSupport::type data;
eprosima::fastdds::dds::SampleInfo info;

while (ReturnCode_t::RETCODE_OK == reader->take_next_sample(&data, &info))
{
participant_->data_received();
}
}

private:

SubListener& operator =(
Expand Down Expand Up @@ -611,6 +623,13 @@ class PubSubParticipant
sub_liveliness_cv_.notify_one();
}

void data_received()
{
std::unique_lock<std::mutex> lock(sub_data_mutex_);
sub_times_data_received_++;
sub_data_cv_.notify_one();
}

unsigned int pub_times_liveliness_lost()
{
std::unique_lock<std::mutex> lock(pub_liveliness_mutex_);
Expand Down Expand Up @@ -717,6 +736,13 @@ class PubSubParticipant
//! A condition variable for liveliness of publisher
std::condition_variable pub_liveliness_cv_;

//! A mutex protecting received data
std::mutex sub_data_mutex_;
//! A condition variable for received data
std::condition_variable sub_data_cv_;
//! Number of times a subscriber received data
size_t sub_times_data_received_ = 0;

eprosima::fastdds::dds::TypeSupport type_;
};

Expand Down

0 comments on commit b53bfb0

Please sign in to comment.