Commit 3e68d7b4 authored by Dave Watson's avatar Dave Watson Committed by Alecs King

runImmediatly fix

Summary: Should also work if eventbase isn't looping

Test Plan: added new unittest

Reviewed By: hans@fb.com

Subscribers: doug, folly-diffs@, yfeldblum, chalfant

FB internal diff: D1984259

Signature: t1:1984259:1428691788:edb89424a48b8071a776d828300b7c1094f1c48f
parent 162c9723
...@@ -611,7 +611,7 @@ bool EventBase::runInEventBaseThreadAndWait(const Cob& fn) { ...@@ -611,7 +611,7 @@ bool EventBase::runInEventBaseThreadAndWait(const Cob& fn) {
} }
bool EventBase::runImmediatelyOrRunInEventBaseThreadAndWait(const Cob& fn) { bool EventBase::runImmediatelyOrRunInEventBaseThreadAndWait(const Cob& fn) {
if (inRunningEventBaseThread()) { if (isInEventBaseThread()) {
fn(); fn();
return true; return true;
} else { } else {
......
...@@ -1246,6 +1246,15 @@ TEST(EventBaseTest, RunImmediatelyOrRunInEventBaseThreadAndWaitWithin) { ...@@ -1246,6 +1246,15 @@ TEST(EventBaseTest, RunImmediatelyOrRunInEventBaseThreadAndWaitWithin) {
}); });
} }
TEST(EventBaseTest, RunImmediatelyOrRunInEventBaseThreadNotLooping) {
EventBase eb;
auto mutated = false;
eb.runImmediatelyOrRunInEventBaseThreadAndWait([&] {
mutated = true;
});
EXPECT_TRUE(mutated);
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Tests for runInLoop() // Tests for runInLoop()
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
......
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