Commit 32f91898 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Fix waiting in UnboundedQueue

Summary:
[Folly] Fix waiting in `UnboundedQueue::dequeue` suite.

`SaturatingSemaphore::try_wait_until` does not return early with the result `false`, so the loop could result in incorrect long waits.

Reviewed By: magedm

Differential Revision: D7151562

fbshipit-source-id: cd90583f0b4520464ed1877df8396df43ebbef00
parent c027cddd
......@@ -444,15 +444,10 @@ class UnboundedQueue {
Entry& e,
Ticket t,
const std::chrono::time_point<Clock, Duration>& deadline) noexcept {
while (true) {
if (LIKELY(e.tryWaitUntil(deadline))) {
return true;
}
if (t >= producerTicket()) {
return false;
}
asm_volatile_pause();
if (LIKELY(e.tryWaitUntil(deadline))) {
return true;
}
return t < producerTicket();
}
/** findSegment */
......
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