Skip to content

Commit

Permalink
Switch to relaxed memory order
Browse files Browse the repository at this point in the history
Fix spelling

Signed-off-by: Antonio Vicente <avd@google.com>
  • Loading branch information
antoniovicente committed Sep 23, 2020
1 parent e9db878 commit 5a3ecaf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 4 additions & 4 deletions source/server/guarddog_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ GuardDogImpl::GuardDogImpl(Stats::Scope& stats_scope, const Server::Configuratio
GuardDogImpl::~GuardDogImpl() { stop(); }

void GuardDogImpl::step() {
// Hold mutex_ for the duration of the step() function to ensure that watchdog liveness checks and
// test interlock operations happen in the expected order. Calls to forceCheckForTest() should
// result in a full iteration of the step() function to process recent watchdog touches and
// monotonic time changes.
// Hold mutex_ for the duration of the step() function to ensure that watchdog still alive checks
// and test interlocks happen in the expected order. Calls to forceCheckForTest() should result in
// a full iteration of the step() function to process recent watchdog touches and monotonic time
// changes.
Thread::LockGuard guard(mutex_);
if (!run_thread_) {
return;
Expand Down
5 changes: 2 additions & 3 deletions source/server/watchdog_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ class WatchDogImpl : public WatchDog {

Thread::ThreadId threadId() const override { return thread_id_; }
// Used by GuardDogImpl determine if the watchdog was touched recently and reset the touch status.
bool getTouchedAndReset() { return touched_.exchange(false, std::memory_order_acq_rel); }
bool getTouchedAndReset() { return touched_.exchange(false, std::memory_order_relaxed); }

// Server::WatchDog
void startWatchdog(Event::Dispatcher& dispatcher) override;
void touch() override {
// Set touched_ if not already set.
bool expected = false;
touched_.compare_exchange_strong(expected, true, std::memory_order_release,
std::memory_order_acquire);
touched_.compare_exchange_strong(expected, true, std::memory_order_relaxed);
}

private:
Expand Down

0 comments on commit 5a3ecaf

Please sign in to comment.