proxygen
folly::observer_detail::ObserverManager::DependencyRecorder Class Reference

#include <ObserverManager.h>

Classes

struct  Dependencies
 

Public Types

using DependencySet = std::unordered_set< Core::Ptr >
 

Public Member Functions

 DependencyRecorder (const Core &core)
 
DependencySet release ()
 
 ~DependencyRecorder ()
 

Static Public Member Functions

static void markDependency (Core::Ptr dependency)
 
static void markRefreshDependency (const Core &core)
 
static void unmarkRefreshDependency (const Core &core)
 

Private Attributes

Dependencies dependencies_
 
DependenciespreviousDepedencies_
 

Static Private Attributes

static FOLLY_TLS DependenciescurrentDependencies_ {nullptr}
 

Detailed Description

Definition at line 137 of file ObserverManager.h.

Member Typedef Documentation

Constructor & Destructor Documentation

folly::observer_detail::ObserverManager::DependencyRecorder::DependencyRecorder ( const Core core)
inlineexplicit
folly::observer_detail::ObserverManager::DependencyRecorder::~DependencyRecorder ( )
inline

Member Function Documentation

static void folly::observer_detail::ObserverManager::DependencyRecorder::markDependency ( Core::Ptr  dependency)
inlinestatic
static void folly::observer_detail::ObserverManager::DependencyRecorder::markRefreshDependency ( const Core core)
inlinestatic

Definition at line 161 of file ObserverManager.h.

References folly::observer_detail::GraphCycleDetector< NodeId >::addEdge(), folly::observer_detail::ObserverManager::DependencyRecorder::Dependencies::core, currentDependencies_, and folly::observer_detail::ObserverManager::getInstance().

Referenced by folly::observer_detail::Core::refresh().

161  {
162  if (!currentDependencies_) {
163  return;
164  }
165 
166  if (auto instance = getInstance()) {
167  instance->cycleDetector_.withLock([&](CycleDetector& cycleDetector) {
168  bool hasCycle =
169  !cycleDetector.addEdge(&currentDependencies_->core, &core);
170  if (hasCycle) {
171  throw std::logic_error("Observer cycle detected.");
172  }
173  });
174  }
175  }
GraphCycleDetector< const Core * > CycleDetector
static std::shared_ptr< ObserverManager > getInstance()
static void folly::observer_detail::ObserverManager::DependencyRecorder::unmarkRefreshDependency ( const Core core)
inlinestatic

Definition at line 177 of file ObserverManager.h.

References folly::observer_detail::ObserverManager::DependencyRecorder::Dependencies::core, currentDependencies_, folly::observer_detail::ObserverManager::getInstance(), and folly::observer_detail::GraphCycleDetector< NodeId >::removeEdge().

Referenced by folly::observer_detail::Core::refresh().

177  {
178  if (!currentDependencies_) {
179  return;
180  }
181 
182  if (auto instance = getInstance()) {
183  instance->cycleDetector_.withLock([&](CycleDetector& cycleDetector) {
184  cycleDetector.removeEdge(&currentDependencies_->core, &core);
185  });
186  }
187  }
GraphCycleDetector< const Core * > CycleDetector
static std::shared_ptr< ObserverManager > getInstance()

Member Data Documentation

FOLLY_TLS ObserverManager::DependencyRecorder::Dependencies * folly::observer_detail::ObserverManager::DependencyRecorder::currentDependencies_ {nullptr}
staticprivate
Dependencies folly::observer_detail::ObserverManager::DependencyRecorder::dependencies_
private

Definition at line 204 of file ObserverManager.h.

Referenced by DependencyRecorder(), release(), and ~DependencyRecorder().

Dependencies* folly::observer_detail::ObserverManager::DependencyRecorder::previousDepedencies_
private

Definition at line 205 of file ObserverManager.h.

Referenced by DependencyRecorder(), and release().


The documentation for this class was generated from the following files: