Commit 6da900e4 authored by Adam Radziwonczyk-Syta's avatar Adam Radziwonczyk-Syta Committed by Facebook Github Bot 4

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<SpecificObserver*>(observer)) {
    specific_observer->set_fiber_name(...);
  }

Reviewed By: andriigrynenko

Differential Revision: D3392890

fbshipit-source-id: 284b4964bbb17e9a081779b870af68e8f1a81634
parent 889fe563
...@@ -154,6 +154,10 @@ void FiberManager::setObserver(ExecutionObserver* observer) { ...@@ -154,6 +154,10 @@ void FiberManager::setObserver(ExecutionObserver* observer) {
observer_ = observer; observer_ = observer;
} }
ExecutionObserver* FiberManager::getObserver() {
return observer_;
}
void FiberManager::setPreemptRunner(InlineFunctionRunner* preemptRunner) { void FiberManager::setPreemptRunner(InlineFunctionRunner* preemptRunner) {
preemptRunner_ = preemptRunner; preemptRunner_ = preemptRunner;
} }
......
...@@ -296,6 +296,12 @@ class FiberManager : public ::folly::Executor { ...@@ -296,6 +296,12 @@ class FiberManager : public ::folly::Executor {
*/ */
void setObserver(ExecutionObserver* observer); void setObserver(ExecutionObserver* observer);
/**
* @return Current observer for this FiberManager. Returns nullptr
* if no observer has been set.
*/
ExecutionObserver* getObserver();
/** /**
* Setup fibers preempt runner. * Setup fibers preempt runner.
*/ */
......
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