Commit dfd3d1ef authored by Dave Watson's avatar Dave Watson Committed by Facebook Github Bot

Sync time compare exchange

Summary: Similar to D7429494, this can be a CAS and save some latency for some readers.

Reviewed By: magedm

Differential Revision: D7505578

fbshipit-source-id: eeeb06c2969a74084edd3df26cf2d135b8b0e132
parent 75765b5c
...@@ -85,11 +85,13 @@ void rcu_domain<Tag>::retire(list_node* node) noexcept { ...@@ -85,11 +85,13 @@ void rcu_domain<Tag>::retire(list_node* node) noexcept {
uint64_t time = std::chrono::duration_cast<std::chrono::milliseconds>( uint64_t time = std::chrono::duration_cast<std::chrono::milliseconds>(
std::chrono::steady_clock::now().time_since_epoch()) std::chrono::steady_clock::now().time_since_epoch())
.count(); .count();
if (time > syncTime_.load(std::memory_order_relaxed) + syncTimePeriod_) { auto syncTime = syncTime_.load(std::memory_order_relaxed);
if (time > syncTime + syncTimePeriod_ &&
syncTime_.compare_exchange_strong(
syncTime, time, std::memory_order_relaxed)) {
list_head finished; list_head finished;
{ {
std::lock_guard<std::mutex> g(syncMutex_); std::lock_guard<std::mutex> g(syncMutex_);
syncTime_.store(time, std::memory_order_relaxed);
half_sync(false, finished); half_sync(false, finished);
} }
// callbacks are called outside of syncMutex_ // callbacks are called outside of syncMutex_
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment