Commit bf3b5e1e authored by Xavier Deguillard's avatar Xavier Deguillard Committed by Facebook GitHub Bot

rcu: narrow some variable to avoid warnings

Summary:
On Windows, MSVC rightfully complains about conversion from uint64_t to uint8_t
and uint32_t. In both cases, the narrowing is acceptable, so let's do that.

Reviewed By: yfeldblum

Differential Revision: D25352231

fbshipit-source-id: aa900fc14a666f1a99bfaa45b1afac02e7209fa3
parent 90f2b499
......@@ -52,10 +52,10 @@ rcu_domain<Tag>::~rcu_domain() {
template <typename Tag>
rcu_token<Tag> rcu_domain<Tag>::lock_shared() {
auto idx = version_.load(std::memory_order_acquire);
idx &= 1;
counters_.increment(idx);
uint8_t epoch = to_narrow(idx & 1);
counters_.increment(epoch);
return rcu_token<Tag>(idx);
return rcu_token<Tag>(epoch);
}
template <typename Tag>
......@@ -129,7 +129,7 @@ void rcu_domain<Tag>::synchronize() noexcept {
}
std::atomic<uint32_t> cutoff{100};
// Wait for someone to finish the work.
turn_.tryWaitForTurn(work, cutoff, false);
turn_.tryWaitForTurn(to_narrow(work), cutoff, false);
}
}
}
......@@ -171,7 +171,7 @@ void rcu_domain<Tag>::half_sync(bool blocking, list_head& finished) {
version_.store(next, std::memory_order_release);
// Notify synchronous waiters in synchronize().
turn_.completeTurn(curr);
turn_.completeTurn(to_narrow(curr));
}
} // namespace folly
......@@ -308,10 +308,10 @@ class rcu_token {
rcu_token& operator=(rcu_token&& other) = default;
private:
explicit rcu_token(uint64_t epoch) : epoch_(epoch) {}
explicit rcu_token(uint8_t epoch) : epoch_(epoch) {}
friend class rcu_domain<Tag>;
uint64_t epoch_;
uint8_t epoch_;
};
// Defines an RCU domain. RCU readers within a given domain block updaters
......
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