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

Let keep-alive tokens from VirtualEventBase be destroyed from any thread

Summary:
[Folly] Let keep-alive tokens from `VirtualEventBase` be destroyed from any thread.

This case was missed in {D5951397} (facebook/folly@6f3b7616f3402355441c62ca60a36159435aa818).

Reviewed By: andriigrynenko

Differential Revision: D5970670

fbshipit-source-id: 19e2b00134516e68113234acd6111e21c3e23e8d
parent 1292801d
......@@ -118,7 +118,6 @@ class VirtualEventBase : public folly::Executor, public folly::TimeoutManager {
/**
* Returns you a handle which prevents VirtualEventBase from being destroyed.
* KeepAlive handle can be released from EventBase loop only.
*/
KeepAlive getKeepAliveToken() override {
DCHECK(loopKeepAliveCount_ + loopKeepAliveCountAtomic_.load() > 0);
......@@ -137,7 +136,9 @@ class VirtualEventBase : public folly::Executor, public folly::TimeoutManager {
protected:
void keepAliveRelease() override {
getEventBase().dcheckIsInEventBaseThread();
if (!getEventBase().inRunningEventBaseThread()) {
return getEventBase().add([=] { keepAliveRelease(); });
}
if (loopKeepAliveCountAtomic_.load()) {
loopKeepAliveCount_ += loopKeepAliveCountAtomic_.exchange(0);
}
......
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