Skip to content

Commit

Permalink
Refs 14069. Linter pass.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Barro <miguelbarro@eprosima.com>
  • Loading branch information
Miguel Barro committed Jun 3, 2022
1 parent 6ccc547 commit 7424022
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
26 changes: 15 additions & 11 deletions include/fastdds/rtps/writer/LivelinessManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ namespace eprosima {
namespace fastrtps {
namespace rtps {

using LivelinessCallback = std::function<void(
const GUID_t&,
const LivelinessQosPolicyKind&,
const Duration_t&,
int32_t alive_change,
int32_t not_alive_change)>;
using LivelinessCallback = std::function<void (
const GUID_t&,
const LivelinessQosPolicyKind&,
const Duration_t&,
int32_t alive_change,
int32_t not_alive_change)>;

/**
* @brief A class managing the liveliness of a set of writers. Writers are represented by their LivelinessData
Expand Down Expand Up @@ -65,7 +65,8 @@ class LivelinessManager
* @brief LivelinessManager
* @param other
*/
LivelinessManager(const LivelinessManager& other) = delete;
LivelinessManager(
const LivelinessManager& other) = delete;

/**
* @brief Adds a writer to the set
Expand Down Expand Up @@ -108,21 +109,23 @@ class LivelinessManager
* @param kind Liveliness kind
* @return True if liveliness was successfully asserted
*/
bool assert_liveliness(LivelinessQosPolicyKind kind);
bool assert_liveliness(
LivelinessQosPolicyKind kind);

/**
* @brief A method to check any writer of the given kind is alive
* @param kind The liveliness kind to check for
* @return True if at least one writer of this kind is alive. False otherwise
*/
bool is_any_alive(LivelinessQosPolicyKind kind);
bool is_any_alive(
LivelinessQosPolicyKind kind);

/**
* @brief A method to return liveliness data
* @details Should only be used for testing purposes
* @return Vector of liveliness data
*/
const ResourceLimitedVector<LivelinessData> &get_liveliness_data() const;
const ResourceLimitedVector<LivelinessData>& get_liveliness_data() const;

private:

Expand All @@ -131,7 +134,8 @@ class LivelinessManager
* @param writer The liveliness data of the writer asserting liveliness
* @pre The collection shared_mutex must be taken for reading
*/
void assert_writer_liveliness(LivelinessData& writer);
void assert_writer_liveliness(
LivelinessData& writer);

/**
* @brief A method to calculate the time when the next writer is going to lose liveliness
Expand Down
23 changes: 12 additions & 11 deletions src/cpp/rtps/writer/LivelinessManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,16 @@ bool LivelinessManager::remove_writer(
// collection guard
std::lock_guard<shared_mutex> _(col_mutex_);

removed = writers_.remove_if([guid, kind, lease_duration, &status, this](LivelinessData& writer){
// writers_ elements guard
std::lock_guard<std::mutex> _(mutex_);
status = writer.status;
return writer.guid == guid &&
writer.kind == kind &&
writer.lease_duration == lease_duration &&
--writer.count == 0;
});
removed = writers_.remove_if([guid, kind, lease_duration, &status, this](LivelinessData& writer)
{
// writers_ elements guard
std::lock_guard<std::mutex> _(mutex_);
status = writer.status;
return writer.guid == guid &&
writer.kind == kind &&
writer.lease_duration == lease_duration &&
--writer.count == 0;
});
}

if (!removed)
Expand Down Expand Up @@ -203,7 +204,7 @@ bool LivelinessManager::assert_liveliness(
}
}

if(!found)
if (!found)
{
return false;
}
Expand Down Expand Up @@ -342,7 +343,7 @@ bool LivelinessManager::timer_expired()
{
lock.lock();

if( timer_owner_ != nullptr)
if ( timer_owner_ != nullptr)
{
// Some times the interval could be negative if a writer expired during the call to this function
// Once in this situation there is not much we can do but let asio timers expire inmediately
Expand Down

0 comments on commit 7424022

Please sign in to comment.