Commit 5ec4d977 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Do nothing in spin_pause_until if spin_max is zero

Summary:
[Folly] Do nothing in `spin_pause_until` if `spin_max` is zero.

Rather than go through the loop at all, if the instruction is not to spin - encoded as `spin_max <= 0` - then return early.

Reviewed By: nbronson

Differential Revision: D6910431

fbshipit-source-id: fa94510e7ec1ebdd7bc3f1a407dcf70e1e153b40
parent 3b08af41
...@@ -31,6 +31,10 @@ bool spin_pause_until( ...@@ -31,6 +31,10 @@ bool spin_pause_until(
std::chrono::time_point<Clock, Duration> const& deadline, std::chrono::time_point<Clock, Duration> const& deadline,
WaitOptions const& opt, WaitOptions const& opt,
F f) { F f) {
if (opt.spin_max() <= opt.spin_max().zero()) {
return false;
}
auto tbegin = Clock::now(); auto tbegin = Clock::now();
while (true) { while (true) {
if (f()) { if (f()) {
......
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