proxygen
folly::observer Namespace Reference

Namespaces

 detail
 

Classes

class  CallbackHandle
 
struct  ObservableTraits
 
class  Observer
 
class  ObserverCreator
 
struct  ObserverTraits
 
struct  ObserverTraits< T, false >
 
struct  ObserverTraits< T, true >
 
class  SimpleObservable
 
class  Snapshot
 
class  TLObserver
 

Typedefs

template<typename T , bool CacheInThreadLocal>
using ObserverT = typename ObserverTraits< T, CacheInThreadLocal >::type
 

Functions

template<typename F >
Observer< observer_detail::ResultOfUnwrapSharedPtr< F > > makeObserver (F &&creator)
 
template<typename F >
Observer< observer_detail::ResultOf< F > > makeObserver (F &&creator)
 
template<typename T >
TLObserver< TmakeTLObserver (Observer< T > observer)
 
template<typename F >
auto makeTLObserver (F &&creator)
 

Typedef Documentation

template<typename T , bool CacheInThreadLocal>
using folly::observer::ObserverT = typedef typename ObserverTraits<T, CacheInThreadLocal>::type

Definition at line 234 of file Observer.h.

Function Documentation

template<typename F >
Observer< observer_detail::ResultOfUnwrapSharedPtr< F > > folly::observer::makeObserver ( F &&  creator)

Definition at line 37 of file Observer-inl.h.

References folly::observer_detail::Core::create(), and folly::observer_detail::ObserverManager::initCore().

Referenced by folly::observer::CallbackHandle::CallbackHandle(), folly::observer::ObserverCreator< Observable, Traits >::getObserver(), makeObserver(), makeObserverRecursion(), makeTLObserver(), and TEST().

38  {
39  auto core = observer_detail::Core::create(
40  [creator = std::forward<F>(creator)]() mutable {
41  return std::static_pointer_cast<const void>(creator());
42  });
43 
44  observer_detail::ObserverManager::initCore(core);
45 
46  return Observer<observer_detail::ResultOfUnwrapSharedPtr<F>>(core);
47 }
template<typename F >
Observer< observer_detail::ResultOf< F > > folly::observer::makeObserver ( F &&  creator)

makeObserver(...) creates a new Observer<T> object given a functor to compute it. The functor can return T or std::shared_ptr<const T>.

makeObserver(...) blocks until the initial version of Observer is computed. If creator functor fails (throws or returns a nullptr) during this first call, the exception is re-thrown by makeObserver(...).

For all subsequent updates if creator functor fails (throws or returs a nullptr), the Observer (and all its dependents) is not updated.

Definition at line 50 of file Observer-inl.h.

References makeObserver().

50  {
51  return makeObserver([creator = std::forward<F>(creator)]() mutable {
52  return std::make_shared<observer_detail::ResultOf<F>>(creator());
53  });
54 }
static std::unique_ptr< Observer< int > > makeObserver()
Definition: RxBenchmark.cpp:25
template<typename T >
TLObserver<T> folly::observer::makeTLObserver ( Observer< T observer)

Same as makeObserver(...), but creates TLObserver.

Definition at line 211 of file Observer.h.

References folly::gen::move.

Referenced by makeTLObserver(), and TEST().

211  {
212  return TLObserver<T>(std::move(observer));
213 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<typename F >
auto folly::observer::makeTLObserver ( F &&  creator)

Definition at line 216 of file Observer.h.

References makeObserver(), and makeTLObserver().

216  {
217  return makeTLObserver(makeObserver(std::forward<F>(creator)));
218 }
static std::unique_ptr< Observer< int > > makeObserver()
Definition: RxBenchmark.cpp:25
auto makeTLObserver(F &&creator)
Definition: Observer.h:216