Commit 109f7655 authored by Andrii Grynenko's avatar Andrii Grynenko Committed by Facebook Github Bot

Implement loopIgnoreKeepAlive()

Summary:
This is useful to fix legacy tests that use loop(), as keep-alive tokens are used more widely.

(Note: this ignores all push blocking failures!)

Reviewed By: yfeldblum

Differential Revision: D8065959

fbshipit-source-id: 2e7a27f538ac9d36eeea7ba3a882633a193141d1
parent 09c8a80a
......@@ -252,11 +252,22 @@ bool EventBase::loop() {
return loopBody();
}
bool EventBase::loopIgnoreKeepAlive() {
if (loopKeepAliveActive_) {
// Make sure NotificationQueue is not counted as one of the readers
// (otherwise loopBody won't return until terminateLoopSoon is called).
fnRunner_->stopConsuming();
fnRunner_->startConsumingInternal(this, queue_.get());
loopKeepAliveActive_ = false;
}
return loopBody(0, true);
}
bool EventBase::loopOnce(int flags) {
return loopBody(flags | EVLOOP_ONCE);
}
bool EventBase::loopBody(int flags) {
bool EventBase::loopBody(int flags, bool ignoreKeepAlive) {
VLOG(5) << "EventBase(): Starting loop.";
DCHECK(!invokingLoop_)
......@@ -294,7 +305,9 @@ bool EventBase::loopBody(int flags) {
}
while (!stop_.load(std::memory_order_relaxed)) {
applyLoopKeepAlive();
if (!ignoreKeepAlive) {
applyLoopKeepAlive();
}
++nextLoopCnt_;
// Run the before loop callbacks
......
......@@ -254,6 +254,12 @@ class EventBase : private boost::noncopyable,
*/
bool loop();
/**
* Same as loop(), but doesn't wait for all keep-alive tokens to be released.
*/
[[deprecated("This should only be used in legacy unit tests")]]
bool loopIgnoreKeepAlive();
/**
* Wait for some events to become active, run them, then return.
*
......@@ -691,7 +697,7 @@ class EventBase : private boost::noncopyable,
typedef LoopCallback::List LoopCallbackList;
class FunctionRunner;
bool loopBody(int flags = 0);
bool loopBody(int flags = 0, bool ignoreKeepAlive = false);
// executes any callbacks queued by runInLoop(); returns false if none found
bool runLoopCallbacks();
......
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