Commit 4a0367d4 authored by Jon Maltiel Swenson's avatar Jon Maltiel Swenson Committed by Facebook Github Bot

Don't hold GlobalCache mutex while scheduling OnDestruction callback

Summary:
Title. This gets rid of benign TSAN lock order inversion detections.

(Note: this ignores all push blocking failures!)

Reviewed By: spalamarchuk

Differential Revision: D13820662

fbshipit-source-id: f092a988faa2cc897a1d046385e4bc4fd0422c7c
parent 3339cfbf
......@@ -19,6 +19,7 @@
#include <unordered_map>
#include <folly/Function.h>
#include <folly/ScopeGuard.h>
#include <folly/Synchronized.h>
#include <folly/ThreadLocal.h>
......@@ -52,14 +53,21 @@ class GlobalCache {
}
FiberManager& getImpl(EventBaseT& evb, const FiberManager::Options& opts) {
bool constructed = false;
SCOPE_EXIT {
if (constructed) {
evb.runOnDestruction(makeOnEventBaseDestructionCallback(evb));
}
};
std::lock_guard<std::mutex> lg(mutex_);
auto& fmPtrRef = map_[&evb];
if (!fmPtrRef) {
constructed = true;
auto loopController = std::make_unique<EventBaseLoopController>();
loopController->attachEventBase(evb);
evb.runOnDestruction(makeOnEventBaseDestructionCallback(evb));
fmPtrRef =
std::make_unique<FiberManager>(std::move(loopController), opts);
}
......
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