Commit 78a00dec authored by Aaryaman Sagar's avatar Aaryaman Sagar Committed by Facebook GitHub Bot

Change ObserverManager::withDependencyRecordingDisabled to a template

Summary: As title.  So things can return non-void from the function

Reviewed By: yfeldblum

Differential Revision: D31038691

fbshipit-source-id: c8a499ffe7e2451cc11dbfb3f7e6e49591a6444c
parent 40bf7f0e
......@@ -22,6 +22,7 @@
#include <folly/experimental/observer/detail/Core.h>
#include <folly/experimental/observer/detail/GraphCycleDetector.h>
#include <folly/fibers/FiberManager.h>
#include <folly/functional/Invoke.h>
#include <folly/futures/Future.h>
#include <folly/synchronization/SanitizeThread.h>
......@@ -125,11 +126,12 @@ class ObserverManager {
static bool isActive() { return currentDependencies_; }
static void withDependencyRecordingDisabled(folly::FunctionRef<void()> f) {
template <typename F>
static invoke_result_t<F> withDependencyRecordingDisabled(F f) {
auto* const dependencies = std::exchange(currentDependencies_, nullptr);
SCOPE_EXIT { currentDependencies_ = dependencies; };
f();
return f();
}
static void markDependency(Core::Ptr dependency) {
......
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