Skip to content

Commit

Permalink
Consider discovery initialized after two heartbeat cycles
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Agüero <caguero@openrobotics.org>
  • Loading branch information
caguero committed Jul 4, 2023
1 parent 4af7653 commit 0f156ff
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions include/gz/transport/Discovery.hh
Original file line number Diff line number Diff line change
Expand Up @@ -713,16 +713,15 @@ namespace ignition
std::lock_guard<std::mutex> lock(this->mutex);
if (!this->initialized)
{
++this->numHeartbeatsUninitialized;
if (this->numHeartbeatsUninitialized == 2)
if (this->numHeartbeatsUninitialized == 2u)
{
// We consider the discovery initialized after two cycles of
// heartbeats sent.
// We consider discovery initialized after two heartbeat cycles.
this->initialized = true;

// Notify anyone waiting for the initialization phase to finish.
this->initializedCv.notify_all();
}
++this->numHeartbeatsUninitialized;
}

this->timeNextHeartbeat = std::chrono::steady_clock::now() +
Expand Down

0 comments on commit 0f156ff

Please sign in to comment.