From 6da900e4c9abd7b23a5e1355a2fd19488462fde3 Mon Sep 17 00:00:00 2001 From: Adam Radziwonczyk-Syta Date: Tue, 7 Jun 2016 12:59:48 -0700 Subject: [PATCH] Expose current observer from FiberManager Summary: Inteded use case is to write tracing code in common components that can adjust its behavior to the current observer. E.g. auto* observer = FiberManager::getUnsafe()->getObserver(); if (auto* specific_observer = dynamic_cast(observer)) { specific_observer->set_fiber_name(...); } Reviewed By: andriigrynenko Differential Revision: D3392890 fbshipit-source-id: 284b4964bbb17e9a081779b870af68e8f1a81634 --- folly/fibers/FiberManager.cpp | 4 ++++ folly/fibers/FiberManager.h | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/folly/fibers/FiberManager.cpp b/folly/fibers/FiberManager.cpp index 99280e82..783f241a 100644 --- a/folly/fibers/FiberManager.cpp +++ b/folly/fibers/FiberManager.cpp @@ -154,6 +154,10 @@ void FiberManager::setObserver(ExecutionObserver* observer) { observer_ = observer; } +ExecutionObserver* FiberManager::getObserver() { + return observer_; +} + void FiberManager::setPreemptRunner(InlineFunctionRunner* preemptRunner) { preemptRunner_ = preemptRunner; } diff --git a/folly/fibers/FiberManager.h b/folly/fibers/FiberManager.h index 117c26cb..25ee78c1 100644 --- a/folly/fibers/FiberManager.h +++ b/folly/fibers/FiberManager.h @@ -296,6 +296,12 @@ class FiberManager : public ::folly::Executor { */ void setObserver(ExecutionObserver* observer); + /** + * @return Current observer for this FiberManager. Returns nullptr + * if no observer has been set. + */ + ExecutionObserver* getObserver(); + /** * Setup fibers preempt runner. */ -- 2.34.1