proxygen
folly::fibers::FiberManager Class Reference

Single-threaded task execution engine. More...

#include <FiberManagerInternal.h>

Inheritance diagram for folly::fibers::FiberManager:
folly::Executor

Classes

struct  AddTaskFinallyHelper
 
struct  AddTaskHelper
 
struct  FibersPoolResizer
 
struct  Options
 
struct  RemoteTask
 

Public Types

using ExceptionCallback = folly::Function< void(std::exception_ptr, std::string)>
 

Public Member Functions

 FiberManager (const FiberManager &)=delete
 
FiberManageroperator= (const FiberManager &)=delete
 
 FiberManager (std::unique_ptr< LoopController > loopController, Options options=Options())
 
template<typename LocalT >
 FiberManager (LocalType< LocalT >, std::unique_ptr< LoopController > loopController, Options options=Options())
 
 ~FiberManager () override
 
LoopControllerloopController ()
 
const LoopControllerloopController () const
 
void loopUntilNoReady ()
 
void loopUntilNoReadyImpl ()
 
bool shouldRunLoopRemote ()
 
bool hasTasks () const
 
bool hasReadyTasks () const
 
void setExceptionCallback (ExceptionCallback ec)
 
template<typename F >
void addTask (F &&func)
 
template<typename F >
auto addTaskFuture (F &&func) -> folly::Future< typename folly::lift_unit< invoke_result_t< F >>::type >
 
template<typename F >
void addTaskRemote (F &&func)
 
template<typename F >
auto addTaskRemoteFuture (F &&func) -> folly::Future< typename folly::lift_unit< invoke_result_t< F >>::type >
 
void add (folly::Func f) override
 
template<typename F , typename G >
void addTaskFinally (F &&func, G &&finally)
 
template<typename F >
invoke_result_t< F > runInMainContext (F &&func)
 
template<typename T >
Tlocal ()
 
size_t fibersAllocated () const
 
size_t fibersPoolSize () const
 
bool hasActiveFiber () const
 
FibercurrentFiber () const
 
size_t stackHighWatermark () const
 
void yield ()
 
void setObserver (ExecutionObserver *observer)
 
ExecutionObservergetObserver ()
 
void setPreemptRunner (InlineFunctionRunner *preemptRunner)
 
size_t runQueueSize () const
 
template<typename T >
TlocalThread ()
 
- Public Member Functions inherited from folly::Executor
virtual ~Executor ()
 
virtual void addWithPriority (Func, int8_t priority)
 
virtual uint8_t getNumPriorities () const
 

Static Public Member Functions

template<typename T >
static FOLLY_EXPORT TlocalThread ()
 
static FiberManagergetFiberManager ()
 
static FiberManagergetFiberManagerUnsafe ()
 
- Static Public Member Functions inherited from folly::Executor
template<typename ExecutorT >
static KeepAlive< ExecutorT > getKeepAliveToken (ExecutorT *executor)
 
template<typename ExecutorT >
static KeepAlive< ExecutorT > getKeepAliveToken (ExecutorT &executor)
 

Private Types

typedef folly::IntrusiveList< Fiber,&Fiber::listHook_FiberTailQueue
 
typedef folly::IntrusiveList< Fiber,&Fiber::globalListHook_GlobalFiberTailQueue
 

Private Member Functions

void activateFiber (Fiber *fiber)
 
void deactivateFiber (Fiber *fiber)
 
void ensureLoopScheduled ()
 
FibergetFiber ()
 
void initLocalData (Fiber &fiber)
 
void doFibersPoolResizing ()
 
void runReadyFiber (Fiber *fiber)
 
void remoteReadyInsert (Fiber *fiber)
 
void registerAlternateSignalStack ()
 

Private Attributes

FiberactiveFiber_ {nullptr}
 
FibercurrentFiber_ {nullptr}
 
FiberTailQueue readyFibers_
 
FiberTailQueue yieldedFibers_
 
FiberTailQueue fibersPool_
 
GlobalFiberTailQueue allFibers_
 
size_t fibersAllocated_ {0}
 
size_t fibersPoolSize_ {0}
 
size_t fibersActive_ {0}
 
size_t fiberId_ {0}
 
size_t maxFibersActiveLastPeriod_ {0}
 
std::unique_ptr< LoopControllerloopController_
 
bool isLoopScheduled_ {false}
 
GuardPageAllocator stackAllocator_
 
const Options options_
 
size_t stackHighWatermark_ {0}
 
folly::Function< void(Fiber &)> awaitFunc_
 
folly::Function< void()> immediateFunc_
 
InlineFunctionRunnerpreemptRunner_ {nullptr}
 
ExecutionObserverobserver_ {nullptr}
 
ExceptionCallback exceptionCallback_
 
folly::AtomicIntrusiveLinkedList< Fiber,&Fiber::nextRemoteReady_remoteReadyQueue_
 
folly::AtomicIntrusiveLinkedList< RemoteTask,&RemoteTask::nextRemoteTaskremoteTaskQueue_
 
ssize_t remoteCount_ {0}
 
std::shared_ptr< TimeoutControllertimeoutManager_
 
FibersPoolResizer fibersPoolResizer_
 
bool fibersPoolResizerScheduled_ {false}
 
std::type_index localType_
 
bool alternateSignalStackRegistered_ {false}
 

Static Private Attributes

static FOLLY_TLS FiberManagercurrentFiberManager_ = nullptr
 

Friends

class Baton
 
class Fiber
 

Additional Inherited Members

- Static Public Attributes inherited from folly::Executor
static const int8_t LO_PRI = SCHAR_MIN
 
static const int8_t MID_PRI = 0
 
static const int8_t HI_PRI = SCHAR_MAX
 
- Protected Member Functions inherited from folly::Executor
virtual bool keepAliveAcquire ()
 
virtual void keepAliveRelease ()
 
- Static Protected Member Functions inherited from folly::Executor
template<typename ExecutorT >
static bool isKeepAliveDummy (const KeepAlive< ExecutorT > &keepAlive)
 
template<typename ExecutorT >
static KeepAlive< ExecutorT > makeKeepAlive (ExecutorT *executor)
 

Detailed Description

Single-threaded task execution engine.

FiberManager allows semi-parallel task execution on the same thread. Each task can notify FiberManager that it is blocked on something (via await()) call. This will pause execution of this task and it will be resumed only when it is unblocked (via setData()).

Definition at line 77 of file FiberManagerInternal.h.

Member Typedef Documentation

Definition at line 129 of file FiberManagerInternal.h.

Constructor & Destructor Documentation

folly::fibers::FiberManager::FiberManager ( const FiberManager )
delete
folly::fibers::FiberManager::FiberManager ( std::unique_ptr< LoopController loopController,
Options  options = Options() 
)
explicit

Initializes, but doesn't start FiberManager loop

Parameters
loopController
optionsFiberManager options

Definition at line 73 of file FiberManager.cpp.

76  : FiberManager(
77  LocalType<void>(),
78  std::move(loopController),
79  std::move(options)) {}
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
FiberManager(const FiberManager &)=delete
template<typename LocalT >
folly::fibers::FiberManager::FiberManager ( LocalType< LocalT >  ,
std::unique_ptr< LoopController loopController,
Options  options = Options() 
)

Initializes, but doesn't start FiberManager loop

Parameters
loopController
optionsFiberManager options
Template Parameters
LocalTonly local of this type may be stored on fibers. Locals of other types will be considered thread-locals.

Definition at line 531 of file FiberManagerInternal-inl.h.

References context, folly::DFATAL, fibersPoolResizer_, localType_, loopController_, name, and timeoutManager_.

535  : loopController_(std::move(loopController__)),
536  stackAllocator_(options.useGuardPages),
537  options_(preprocessOptions(std::move(options))),
538  exceptionCallback_([](std::exception_ptr eptr, std::string context) {
539  try {
541  } catch (const std::exception& e) {
542  LOG(DFATAL) << "Exception " << typeid(e).name() << " with message '"
543  << e.what() << "' was thrown in "
544  << "FiberManager with context '" << context << "'";
545  } catch (...) {
546  LOG(DFATAL) << "Unknown exception was thrown in FiberManager with "
547  << "context '" << context << "'";
548  }
549  }),
550  timeoutManager_(std::make_shared<TimeoutController>(*loopController_)),
551  fibersPoolResizer_(*this),
552  localType_(typeid(LocalT)) {
553  loopController_->setFiberManager(this);
554 }
void rethrow_exception(std::exception_ptr ep)
context
Definition: CMakeCache.txt:563
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::unique_ptr< LoopController > loopController_
const char * name
Definition: http_parser.c:437
std::shared_ptr< TimeoutController > timeoutManager_
const char * string
Definition: Conv.cpp:212
folly::fibers::FiberManager::~FiberManager ( )
override

Definition at line 81 of file FiberManager.cpp.

References fibersActive_, fibersPool_, loopController_, and readyFibers_.

81  {
82  loopController_.reset();
83 
84  while (!fibersPool_.empty()) {
85  fibersPool_.pop_front_and_dispose([](Fiber* fiber) { delete fiber; });
86  }
87  assert(readyFibers_.empty());
88  assert(fibersActive_ == 0);
89 }
std::unique_ptr< LoopController > loopController_

Member Function Documentation

void folly::fibers::FiberManager::activateFiber ( Fiber fiber)
inlineprivate

Definition at line 59 of file FiberManagerInternal-inl.h.

References folly::fibers::FiberImpl::activate(), activeFiber_, folly::fibers::Fiber::fiberImpl_, folly::fibers::Fiber::getStack(), and SCOPE_EXIT.

Referenced by runReadyFiber().

59  {
60  DCHECK_EQ(activeFiber_, (Fiber*)nullptr);
61 
62 #ifdef FOLLY_SANITIZE_ADDRESS
63  DCHECK(!fiber->asanMainStackBase_);
64  DCHECK(!fiber->asanMainStackSize_);
65  auto stack = fiber->getStack();
66  void* asanFakeStack;
67  registerStartSwitchStackWithAsan(&asanFakeStack, stack.first, stack.second);
68  SCOPE_EXIT {
69  registerFinishSwitchStackWithAsan(asanFakeStack, nullptr, nullptr);
70  fiber->asanMainStackBase_ = nullptr;
71  fiber->asanMainStackSize_ = 0;
72  };
73 #endif
74 
75  activeFiber_ = fiber;
76  fiber->fiberImpl_.activate();
77 }
FiberImpl fiberImpl_
Definition: Fiber.h:112
#define SCOPE_EXIT
Definition: ScopeGuard.h:274
void folly::fibers::FiberManager::add ( folly::Func  )
inlineoverridevirtual

Enqueue a function to executed by this executor. This and all variants must be threadsafe.

Implements folly::Executor.

Definition at line 239 of file FiberManagerInternal.h.

References folly::fibers::addTaskFinally(), FOLLY_EXPORT, folly::fibers::local(), folly::gen::move, folly::fibers::runInMainContext(), and folly::T.

Referenced by folly::FiberIOExecutor::add(), and AtomicBatchDispatcherTesting::dispatchJobs().

239  {
241  }
auto f
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<typename F >
void folly::fibers::FiberManager::addTask ( F &&  func)

Add a new task to be executed. Must be called from FiberManager's thread.

Parameters
funcTask functor; must have a signature of void func(). The object will be destroyed once task execution is complete.

Definition at line 306 of file FiberManagerInternal-inl.h.

References ensureLoopScheduled(), getFiber(), initLocalData(), observer_, readyFibers_, and folly::ExecutionObserver::runnable().

Referenced by folly::fibers::addTask(), BENCHMARK(), main(), runBenchmark(), TEST(), and testFiberLocal().

306  {
307  typedef AddTaskHelper<F> Helper;
308 
309  auto fiber = getFiber();
310  initLocalData(*fiber);
311 
312  if (Helper::allocateInBuffer) {
313  auto funcLoc = static_cast<typename Helper::Func*>(fiber->getUserBuffer());
314  new (funcLoc) typename Helper::Func(std::forward<F>(func), *this);
315 
316  fiber->setFunction(std::ref(*funcLoc));
317  } else {
318  auto funcLoc = new typename Helper::Func(std::forward<F>(func), *this);
319 
320  fiber->setFunction(std::ref(*funcLoc));
321  }
322 
323  readyFibers_.push_back(*fiber);
324  if (observer_) {
325  observer_->runnable(reinterpret_cast<uintptr_t>(fiber));
326  }
327 
329 }
virtual void runnable(uintptr_t id) noexcept=0
Function< void()> Func
Definition: Executor.h:27
template<typename F , typename G >
void folly::fibers::FiberManager::addTaskFinally ( F &&  func,
G &&  finally 
)

Add a new task. When the task is complete, execute finally(Try<Result>&&) on the main context.

Parameters
funcTask functor; must have a signature of T func() for some T.
finallyFinally functor; must have a signature of void finally(Try<T>&&) and will be passed the result of func() (including the exception if occurred).

Definition at line 417 of file FiberManagerInternal-inl.h.

References ensureLoopScheduled(), getFiber(), initLocalData(), observer_, readyFibers_, folly::ExecutionObserver::runnable(), type, and folly::value().

Referenced by folly::fibers::addTaskFinally(), and TEST().

417  {
418  typedef invoke_result_t<F> Result;
419 
420  static_assert(
421  IsRvalueRefTry<typename FirstArgOf<G>::type>::value,
422  "finally(arg): arg must be Try<T>&&");
423  static_assert(
424  std::is_convertible<
425  Result,
426  typename std::remove_reference<
427  typename FirstArgOf<G>::type>::type::element_type>::value,
428  "finally(Try<T>&&): T must be convertible from func()'s return type");
429 
430  auto fiber = getFiber();
431  initLocalData(*fiber);
432 
433  typedef AddTaskFinallyHelper<
434  typename std::decay<F>::type,
435  typename std::decay<G>::type>
436  Helper;
437 
438  if (Helper::allocateInBuffer) {
439  auto funcLoc = static_cast<typename Helper::Func*>(fiber->getUserBuffer());
440  auto finallyLoc =
441  static_cast<typename Helper::Finally*>(static_cast<void*>(funcLoc + 1));
442 
443  new (finallyLoc) typename Helper::Finally(std::forward<G>(finally), *this);
444  new (funcLoc) typename Helper::Func(std::forward<F>(func), *finallyLoc);
445 
446  fiber->setFunctionFinally(std::ref(*funcLoc), std::ref(*finallyLoc));
447  } else {
448  auto finallyLoc =
449  new typename Helper::Finally(std::forward<G>(finally), *this);
450  auto funcLoc =
451  new typename Helper::Func(std::forward<F>(func), *finallyLoc);
452 
453  fiber->setFunctionFinally(std::ref(*funcLoc), std::ref(*finallyLoc));
454  }
455 
456  readyFibers_.push_back(*fiber);
457  if (observer_) {
458  observer_->runnable(reinterpret_cast<uintptr_t>(fiber));
459  }
460 
462 }
PskType type
virtual void runnable(uintptr_t id) noexcept=0
Function< void()> Func
Definition: Executor.h:27
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
template<typename F >
auto folly::fibers::FiberManager::addTaskFuture ( F &&  func) -> folly::Future<typename folly::lift_unit<invoke_result_t<F>>::type>

Add a new task to be executed and return a future that will be set on return from func. Must be called from FiberManager's thread.

Parameters
funcTask functor; must have a signature of void func(). The object will be destroyed once task execution is complete.

Definition at line 25 of file FiberManager-inl.h.

References folly::fibers::addTaskFinally(), f, folly::Promise< T >::getFuture(), folly::gen::move, folly::Promise< T >::setTry(), folly::pushmi::detail::t, and folly::T.

Referenced by TEST().

26  {
27  using T = invoke_result_t<F>;
28  using FutureT = typename folly::lift_unit<T>::type;
29 
31  auto f = p.getFuture();
33  [func = std::forward<F>(func)]() mutable { return func(); },
34  [p = std::move(p)](folly::Try<T>&& t) mutable {
35  p.setTry(std::move(t));
36  });
37  return f;
38 }
auto f
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void addTaskFinally(F &&func, G &&finally)
folly::std T
void setTry(Try< T > &&t)
Definition: Promise-inl.h:122
Future< T > getFuture()
Definition: Promise-inl.h:97
Definition: Try.h:51
template<typename F >
void folly::fibers::FiberManager::addTaskRemote ( F &&  func)

Add a new task to be executed. Safe to call from other threads.

Parameters
funcTask function; must have a signature of void func(). The object will be destroyed once task execution is complete.

Definition at line 332 of file FiberManagerInternal-inl.h.

References getFiberManagerUnsafe(), localType_, loopController_, and remoteTaskQueue_.

Referenced by TEST(), and testFiberLocal().

332  {
333  auto task = [&]() {
334  auto currentFm = getFiberManagerUnsafe();
335  if (currentFm && currentFm->currentFiber_ &&
336  currentFm->localType_ == localType_) {
337  return std::make_unique<RemoteTask>(
338  std::forward<F>(func), currentFm->currentFiber_->localData_);
339  }
340  return std::make_unique<RemoteTask>(std::forward<F>(func));
341  }();
342  if (remoteTaskQueue_.insertHead(task.release())) {
343  loopController_->scheduleThreadSafe();
344  }
345 }
std::unique_ptr< LoopController > loopController_
static FiberManager * getFiberManagerUnsafe()
folly::AtomicIntrusiveLinkedList< RemoteTask,&RemoteTask::nextRemoteTask > remoteTaskQueue_
template<typename F >
auto folly::fibers::FiberManager::addTaskRemoteFuture ( F &&  func) -> folly::Future<typename folly::lift_unit<invoke_result_t<F>>::type>

Add a new task to be executed and return a future that will be set on return from func. Safe to call from other threads.

Parameters
funcTask function; must have a signature of void func(). The object will be destroyed once task execution is complete.

Definition at line 41 of file FiberManager-inl.h.

References f, folly::Promise< T >::getFuture(), folly::makeTryWith(), folly::gen::move, folly::fibers::runInMainContext(), folly::Promise< T >::setTry(), folly::pushmi::detail::t, and type.

Referenced by TEST().

42  {
44  auto f = p.getFuture();
46  [p = std::move(p), func = std::forward<F>(func), this]() mutable {
47  auto t = folly::makeTryWith(std::forward<F>(func));
48  runInMainContext([&]() { p.setTry(std::move(t)); });
49  });
50  return f;
51 }
auto f
PskType type
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
invoke_result_t< F > runInMainContext(F &&func)
void setTry(Try< T > &&t)
Definition: Promise-inl.h:122
Future< T > getFuture()
Definition: Promise-inl.h:97
std::enable_if< !std::is_same< invoke_result_t< F >, void >::value, Try< invoke_result_t< F > > >::type makeTryWith(F &&f)
Definition: Try-inl.h:223
Fiber* folly::fibers::FiberManager::currentFiber ( ) const
inline
Returns
The currently running fiber or null if no fiber is executing.

Definition at line 297 of file FiberManagerInternal.h.

References folly::fibers::yield().

297  {
298  return currentFiber_;
299  }
void folly::fibers::FiberManager::deactivateFiber ( Fiber fiber)
inlineprivate

Definition at line 79 of file FiberManagerInternal-inl.h.

References activeFiber_, folly::fibers::FiberImpl::deactivate(), folly::fibers::Fiber::fiberImpl_, and SCOPE_EXIT.

Referenced by folly::fibers::Fiber::fiberFunc(), and folly::fibers::Fiber::preempt().

79  {
80  DCHECK_EQ(activeFiber_, fiber);
81 
82 #ifdef FOLLY_SANITIZE_ADDRESS
83  DCHECK(fiber->asanMainStackBase_);
84  DCHECK(fiber->asanMainStackSize_);
85 
86  registerStartSwitchStackWithAsan(
87  &fiber->asanFakeStack_,
88  fiber->asanMainStackBase_,
89  fiber->asanMainStackSize_);
90  SCOPE_EXIT {
91  registerFinishSwitchStackWithAsan(
92  fiber->asanFakeStack_,
93  &fiber->asanMainStackBase_,
94  &fiber->asanMainStackSize_);
95  fiber->asanFakeStack_ = nullptr;
96  };
97 #endif
98 
99  activeFiber_ = nullptr;
100  fiber->fiberImpl_.deactivate();
101 }
FiberImpl fiberImpl_
Definition: Fiber.h:112
#define SCOPE_EXIT
Definition: ScopeGuard.h:274
void folly::fibers::FiberManager::doFibersPoolResizing ( )
private
void folly::fibers::FiberManager::ensureLoopScheduled ( )
inlineprivate

Schedules a loop with loopController (unless already scheduled before).

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

References isLoopScheduled_, and loopController_.

Referenced by addTask(), addTaskFinally(), loopUntilNoReadyImpl(), and folly::fibers::Fiber::resume().

50  {
51  if (isLoopScheduled_) {
52  return;
53  }
54 
55  isLoopScheduled_ = true;
56  loopController_->schedule();
57 }
std::unique_ptr< LoopController > loopController_
size_t folly::fibers::FiberManager::fibersAllocated ( ) const
Returns
How many fiber objects (and stacks) has this manager allocated.

Definition at line 137 of file FiberManager.cpp.

References fibersAllocated_.

Referenced by TEST().

137  {
138  return fibersAllocated_;
139 }
size_t folly::fibers::FiberManager::fibersPoolSize ( ) const
Returns
How many of the allocated fiber objects are currently in the free pool.

Definition at line 141 of file FiberManager.cpp.

References fibersPoolSize_.

Referenced by BENCHMARK(), and TEST().

141  {
142  return fibersPoolSize_;
143 }
Fiber * folly::fibers::FiberManager::getFiber ( )
private
Returns
An initialized Fiber object from the pool

Definition at line 104 of file FiberManager.cpp.

References Fiber, fiberId_, fibersActive_, fibersAllocated_, fibersPool_, folly::fibers::FiberManager::Options::fibersPoolResizePeriodMs, fibersPoolResizer_, fibersPoolResizerScheduled_, fibersPoolSize_, folly::fibers::Fiber::init(), maxFibersActiveLastPeriod_, options_, and folly::fibers::FiberManager::Options::recordStackEvery.

Referenced by addTask(), addTaskFinally(), and loopUntilNoReadyImpl().

104  {
105  Fiber* fiber = nullptr;
106 
110  }
111 
112  if (fibersPool_.empty()) {
113  fiber = new Fiber(*this);
115  } else {
116  fiber = &fibersPool_.front();
117  fibersPool_.pop_front();
118  assert(fibersPoolSize_ > 0);
119  --fibersPoolSize_;
120  }
121  assert(fiber);
124  }
125  ++fiberId_;
126  bool recordStack = (options_.recordStackEvery != 0) &&
128  fiber->init(recordStack);
129  return fiber;
130 }
FiberManager & folly::fibers::FiberManager::getFiberManager ( )
inlinestatic

Definition at line 483 of file FiberManagerInternal-inl.h.

References currentFiberManager_.

Referenced by folly::fibers::addTask(), and folly::fibers::addTaskFinally().

483  {
484  assert(currentFiberManager_ != nullptr);
485  return *currentFiberManager_;
486 }
static FOLLY_TLS FiberManager * currentFiberManager_
FiberManager * folly::fibers::FiberManager::getFiberManagerUnsafe ( )
inlinestatic
ExecutionObserver * folly::fibers::FiberManager::getObserver ( )
Returns
Current observer for this FiberManager. Returns nullptr if no observer has been set.

Definition at line 162 of file FiberManager.cpp.

References observer_.

162  {
163  return observer_;
164 }
bool folly::fibers::FiberManager::hasActiveFiber ( ) const
inline

return true if running activeFiber_ is not nullptr.

Definition at line 492 of file FiberManagerInternal-inl.h.

References activeFiber_.

Referenced by TEST().

492  {
493  return activeFiber_ != nullptr;
494 }
bool folly::fibers::FiberManager::hasReadyTasks ( ) const
inline
Returns
true if there are tasks ready to run.

Definition at line 267 of file FiberManagerInternal-inl.h.

References readyFibers_, remoteReadyQueue_, and remoteTaskQueue_.

Referenced by folly::fibers::EventBaseLoopController::runLoop().

267  {
268  return !readyFibers_.empty() || !remoteReadyQueue_.empty() ||
269  !remoteTaskQueue_.empty();
270 }
folly::AtomicIntrusiveLinkedList< Fiber,&Fiber::nextRemoteReady_ > remoteReadyQueue_
folly::AtomicIntrusiveLinkedList< RemoteTask,&RemoteTask::nextRemoteTask > remoteTaskQueue_
bool folly::fibers::FiberManager::hasTasks ( ) const
Returns
true if there are outstanding tasks.

Definition at line 99 of file FiberManager.cpp.

References fibersActive_, remoteCount_, remoteReadyQueue_, and remoteTaskQueue_.

Referenced by folly::fibers::SimpleLoopController::loop(), folly::fibers::ExecutorLoopController::runLoop(), folly::fibers::EventBaseLoopController::runLoop(), folly::fibers::EventBaseLoopController::scheduleThreadSafe(), TEST(), and testFiberLocal().

99  {
100  return fibersActive_ > 0 || !remoteReadyQueue_.empty() ||
101  !remoteTaskQueue_.empty() || remoteCount_ > 0;
102 }
folly::AtomicIntrusiveLinkedList< Fiber,&Fiber::nextRemoteReady_ > remoteReadyQueue_
folly::AtomicIntrusiveLinkedList< RemoteTask,&RemoteTask::nextRemoteTask > remoteTaskQueue_
void folly::fibers::FiberManager::initLocalData ( Fiber fiber)
inlineprivate

Sets local data for given fiber if all conditions are met.

Definition at line 522 of file FiberManagerInternal-inl.h.

References getFiberManagerUnsafe(), folly::fibers::Fiber::localData_, localType_, folly::fibers::Fiber::rcontext_, and folly::RequestContext::saveContext().

Referenced by addTask(), and addTaskFinally().

522  {
523  auto fm = getFiberManagerUnsafe();
524  if (fm && fm->currentFiber_ && fm->localType_ == localType_) {
525  fiber.localData_ = fm->currentFiber_->localData_;
526  }
527  fiber.rcontext_ = RequestContext::saveContext();
528 }
static std::shared_ptr< RequestContext > saveContext()
Definition: Request.h:196
static FiberManager * getFiberManagerUnsafe()
template<typename T >
T & folly::fibers::FiberManager::local ( )

Returns a refference to a fiber-local context for given Fiber. Should be always called with the same T for each fiber. Fiber-local context is lazily default-constructed on first request. When new task is scheduled via addTask / addTaskRemote from a fiber its fiber-local context is copied into the new fiber.

Definition at line 504 of file FiberManagerInternal-inl.h.

References currentFiber_, folly::fibers::Fiber::LocalData::get(), folly::fibers::Fiber::localData_, localType_, and folly::T.

504  {
505  if (std::type_index(typeid(T)) == localType_ && currentFiber_) {
506  return currentFiber_->localData_.get<T>();
507  }
508  return localThread<T>();
509 }
folly::std T
LocalData localData_
Definition: Fiber.h:173
template<typename T >
static FOLLY_EXPORT T& folly::fibers::FiberManager::localThread ( )
static
template<typename T >
T& folly::fibers::FiberManager::localThread ( )

Definition at line 512 of file FiberManagerInternal-inl.h.

References folly::pushmi::detail::t, and folly::T.

512  {
513 #ifndef __APPLE__
514  static thread_local T t;
515  return t;
516 #else // osx doesn't support thread_local
517  static ThreadLocal<T> t;
518  return *t;
519 #endif
520 }
folly::std T
LoopController & folly::fibers::FiberManager::loopController ( )

Controller access.

Definition at line 91 of file FiberManager.cpp.

References loopController_.

Referenced by main(), runBenchmark(), and TEST().

91  {
92  return *loopController_;
93 }
std::unique_ptr< LoopController > loopController_
const LoopController & folly::fibers::FiberManager::loopController ( ) const

Definition at line 95 of file FiberManager.cpp.

References loopController_.

95  {
96  return *loopController_;
97 }
std::unique_ptr< LoopController > loopController_
void folly::fibers::FiberManager::loopUntilNoReady ( )
inline

Keeps running ready tasks until the list of ready tasks is empty.

Definition at line 186 of file FiberManagerInternal-inl.h.

References loopController_.

Referenced by BENCHMARK(), TEST(), and testFiberLocal().

186  {
187  return loopController_->runLoop();
188 }
std::unique_ptr< LoopController > loopController_
void folly::fibers::FiberManager::loopUntilNoReadyImpl ( )
inline

This should only be called by a LoopController.

Definition at line 190 of file FiberManagerInternal-inl.h.

References alternateSignalStackRegistered_, currentFiberManager_, ensureLoopScheduled(), folly::fibers::FiberManager::RemoteTask::func, getFiber(), isLoopScheduled_, folly::fibers::FiberManager::RemoteTask::localData, folly::fibers::Fiber::localData_, folly::gen::move, observer_, folly::fibers::FiberManager::RemoteTask::rcontext, folly::fibers::Fiber::rcontext_, readyFibers_, registerAlternateSignalStack(), remoteCount_, remoteReadyQueue_, remoteTaskQueue_, folly::ExecutionObserver::runnable(), runReadyFiber(), folly::RequestContext::saveContext(), SCOPE_EXIT, folly::RequestContext::setContext(), folly::fibers::Fiber::setFunction(), folly::f14::swap(), UNLIKELY, and yieldedFibers_.

Referenced by folly::fibers::ExecutorLoopController::runLoop(), folly::fibers::EventBaseLoopController::runLoop(), and folly::fibers::SimpleLoopController::runLoop().

190  {
191 #ifndef _WIN32
194  }
195 #endif
196 
197  // Support nested FiberManagers
198  auto originalFiberManager = this;
199  std::swap(currentFiberManager_, originalFiberManager);
200 
201  // Save current context, and reset it after executing all fibers.
202  // This can avoid a lot of context swapping,
203  // if the Fibers share the same context
204  auto curCtx = RequestContext::saveContext();
205 
206  SCOPE_EXIT {
208  isLoopScheduled_ = false;
209  if (!readyFibers_.empty()) {
211  }
212  std::swap(currentFiberManager_, originalFiberManager);
213  CHECK_EQ(this, originalFiberManager);
214  };
215 
216  bool hadRemote = true;
217  while (hadRemote) {
218  while (!readyFibers_.empty()) {
219  auto& fiber = readyFibers_.front();
220  readyFibers_.pop_front();
221  runReadyFiber(&fiber);
222  }
223 
224  auto hadRemoteFiber = remoteReadyQueue_.sweepOnce(
225  [this](Fiber* fiber) { runReadyFiber(fiber); });
226 
227  if (hadRemoteFiber) {
228  ++remoteCount_;
229  }
230 
231  auto hadRemoteTask =
232  remoteTaskQueue_.sweepOnce([this](RemoteTask* taskPtr) {
233  std::unique_ptr<RemoteTask> task(taskPtr);
234  auto fiber = getFiber();
235  if (task->localData) {
236  fiber->localData_ = *task->localData;
237  }
238  fiber->rcontext_ = std::move(task->rcontext);
239 
240  fiber->setFunction(std::move(task->func));
241  if (observer_) {
242  observer_->runnable(reinterpret_cast<uintptr_t>(fiber));
243  }
244  runReadyFiber(fiber);
245  });
246 
247  if (hadRemoteTask) {
248  ++remoteCount_;
249  }
250 
251  hadRemote = hadRemoteTask || hadRemoteFiber;
252  }
253 
254  if (observer_) {
255  for (auto& yielded : yieldedFibers_) {
256  observer_->runnable(reinterpret_cast<uintptr_t>(&yielded));
257  }
258  }
260 }
static std::shared_ptr< RequestContext > setContext(std::shared_ptr< RequestContext > ctx)
Definition: Request.cpp:227
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static FOLLY_TLS FiberManager * currentFiberManager_
#define SCOPE_EXIT
Definition: ScopeGuard.h:274
virtual void runnable(uintptr_t id) noexcept=0
static std::shared_ptr< RequestContext > saveContext()
Definition: Request.h:196
folly::AtomicIntrusiveLinkedList< Fiber,&Fiber::nextRemoteReady_ > remoteReadyQueue_
void swap(SwapTrackingAlloc< T > &, SwapTrackingAlloc< T > &)
Definition: F14TestUtil.h:414
folly::AtomicIntrusiveLinkedList< RemoteTask,&RemoteTask::nextRemoteTask > remoteTaskQueue_
#define UNLIKELY(x)
Definition: Likely.h:48
FiberManager& folly::fibers::FiberManager::operator= ( const FiberManager )
delete
void folly::fibers::FiberManager::registerAlternateSignalStack ( )
private
void folly::fibers::FiberManager::remoteReadyInsert ( Fiber fiber)
private

Definition at line 149 of file FiberManager.cpp.

References loopController_, observer_, remoteReadyQueue_, and folly::ExecutionObserver::runnable().

Referenced by folly::fibers::Fiber::resume().

149  {
150  if (observer_) {
151  observer_->runnable(reinterpret_cast<uintptr_t>(fiber));
152  }
153  if (remoteReadyQueue_.insertHead(fiber)) {
154  loopController_->scheduleThreadSafe();
155  }
156 }
virtual void runnable(uintptr_t id) noexcept=0
std::unique_ptr< LoopController > loopController_
folly::AtomicIntrusiveLinkedList< Fiber,&Fiber::nextRemoteReady_ > remoteReadyQueue_
template<typename F >
invoke_result_t< F > folly::fibers::FiberManager::runInMainContext ( F &&  func)

If called from a fiber, immediately switches to the FiberManager's context and runs func(), going back to the Fiber's context after completion. Outside a fiber, just calls func() directly.

Returns
value returned by func().

Definition at line 465 of file FiberManagerInternal-inl.h.

References activeFiber_, folly::fibers::Fiber::AWAITING_IMMEDIATE, f, immediateFunc_, folly::gen::move, folly::fibers::Fiber::preempt(), folly::tryEmplaceWith(), and UNLIKELY.

Referenced by TEST().

465  {
466  if (UNLIKELY(activeFiber_ == nullptr)) {
467  return func();
468  }
469 
470  typedef invoke_result_t<F> Result;
471 
472  folly::Try<Result> result;
473  auto f = [&func, &result]() mutable {
474  folly::tryEmplaceWith(result, std::forward<F>(func));
475  };
476 
477  immediateFunc_ = std::ref(f);
479 
480  return std::move(result).value();
481 }
auto f
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
T * tryEmplaceWith(Try< T > &t, Func &&func) noexcept
Definition: Try-inl.h:266
void preempt(State state)
Definition: Fiber.cpp:172
#define UNLIKELY(x)
Definition: Likely.h:48
folly::Function< void()> immediateFunc_
size_t folly::fibers::FiberManager::runQueueSize ( ) const
inline

Returns an estimate of the number of fibers which are waiting to run (does not include fibers or tasks scheduled remotely).

Definition at line 337 of file FiberManagerInternal.h.

References folly::fibers::getFiberManager().

337  {
338  return readyFibers_.size() + yieldedFibers_.size();
339  }
void folly::fibers::FiberManager::runReadyFiber ( Fiber fiber)
inlineprivate

Definition at line 103 of file FiberManagerInternal-inl.h.

References activateFiber(), activeFiber_, awaitFunc_, folly::fibers::Fiber::AWAITING, folly::fibers::Fiber::AWAITING_IMMEDIATE, currentFiber_, exceptionCallback_, fibersActive_, fibersAllocated_, fibersPool_, folly::fibers::FiberManager::Options::fibersPoolResizePeriodMs, fibersPoolSize_, folly::fibers::Fiber::finallyFunc_, folly::fibers::Fiber::func_, immediateFunc_, folly::fibers::Fiber::INVALID, folly::fibers::Fiber::localData_, folly::fibers::FiberManager::Options::maxFibersPoolSize, folly::gen::move, folly::fibers::Fiber::NOT_STARTED, observer_, options_, folly::fibers::Fiber::rcontext_, folly::fibers::Fiber::READY_TO_RUN, folly::fibers::Fiber::LocalData::reset(), folly::fibers::Fiber::resultFunc_, folly::RequestContext::saveContext(), SCOPE_EXIT, folly::RequestContext::setContext(), folly::ExecutionObserver::starting(), folly::fibers::Fiber::state_, folly::ExecutionObserver::stopped(), folly::fibers::Fiber::YIELDED, and yieldedFibers_.

Referenced by loopUntilNoReadyImpl().

103  {
104  SCOPE_EXIT {
105  assert(currentFiber_ == nullptr);
106  assert(activeFiber_ == nullptr);
107  };
108 
109  assert(
110  fiber->state_ == Fiber::NOT_STARTED ||
111  fiber->state_ == Fiber::READY_TO_RUN);
112  currentFiber_ = fiber;
113  // Note: resetting the context is handled by the loop
114  RequestContext::setContext(std::move(fiber->rcontext_));
115  if (observer_) {
116  observer_->starting(reinterpret_cast<uintptr_t>(fiber));
117  }
118 
119  while (fiber->state_ == Fiber::NOT_STARTED ||
120  fiber->state_ == Fiber::READY_TO_RUN) {
121  activateFiber(fiber);
122  if (fiber->state_ == Fiber::AWAITING_IMMEDIATE) {
123  try {
124  immediateFunc_();
125  } catch (...) {
126  exceptionCallback_(std::current_exception(), "running immediateFunc_");
127  }
128  immediateFunc_ = nullptr;
129  fiber->state_ = Fiber::READY_TO_RUN;
130  }
131  }
132 
133  if (fiber->state_ == Fiber::AWAITING) {
134  awaitFunc_(*fiber);
135  awaitFunc_ = nullptr;
136  if (observer_) {
137  observer_->stopped(reinterpret_cast<uintptr_t>(fiber));
138  }
139  currentFiber_ = nullptr;
141  } else if (fiber->state_ == Fiber::INVALID) {
142  assert(fibersActive_ > 0);
143  --fibersActive_;
144  // Making sure that task functor is deleted once task is complete.
145  // NOTE: we must do it on main context, as the fiber is not
146  // running at this point.
147  fiber->func_ = nullptr;
148  fiber->resultFunc_ = nullptr;
149  if (fiber->finallyFunc_) {
150  try {
151  fiber->finallyFunc_();
152  } catch (...) {
153  exceptionCallback_(std::current_exception(), "running finallyFunc_");
154  }
155  fiber->finallyFunc_ = nullptr;
156  }
157  // Make sure LocalData is not accessible from its destructor
158  if (observer_) {
159  observer_->stopped(reinterpret_cast<uintptr_t>(fiber));
160  }
161  currentFiber_ = nullptr;
163  fiber->localData_.reset();
164  fiber->rcontext_.reset();
165 
168  fibersPool_.push_front(*fiber);
169  ++fibersPoolSize_;
170  } else {
171  delete fiber;
172  assert(fibersAllocated_ > 0);
174  }
175  } else if (fiber->state_ == Fiber::YIELDED) {
176  if (observer_) {
177  observer_->stopped(reinterpret_cast<uintptr_t>(fiber));
178  }
179  currentFiber_ = nullptr;
181  fiber->state_ = Fiber::READY_TO_RUN;
182  yieldedFibers_.push_back(*fiber);
183  }
184 }
static std::shared_ptr< RequestContext > setContext(std::shared_ptr< RequestContext > ctx)
Definition: Request.cpp:227
folly::Function< void(Fiber &)> awaitFunc_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
#define SCOPE_EXIT
Definition: ScopeGuard.h:274
static std::shared_ptr< RequestContext > saveContext()
Definition: Request.h:196
std::shared_ptr< RequestContext > rcontext_
Definition: Fiber.h:113
virtual void stopped(uintptr_t id) noexcept=0
virtual void starting(uintptr_t id) noexcept=0
folly::Function< void()> immediateFunc_
void folly::fibers::FiberManager::setExceptionCallback ( FiberManager::ExceptionCallback  ec)

Sets exception callback which will be called if any of the tasks throws an exception.

Parameters
ec

Definition at line 132 of file FiberManager.cpp.

References exceptionCallback_, and folly::gen::move.

132  {
133  assert(ec);
135 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void folly::fibers::FiberManager::setObserver ( ExecutionObserver observer)

Setup fibers execution observation/instrumentation. Fiber locals are available to observer.

Parameters
observerFiber's execution observer.

Definition at line 158 of file FiberManager.cpp.

References observer_.

158  {
159  observer_ = observer;
160 }
void folly::fibers::FiberManager::setPreemptRunner ( InlineFunctionRunner preemptRunner)

Setup fibers preempt runner.

Definition at line 166 of file FiberManager.cpp.

References preemptRunner_.

166  {
167  preemptRunner_ = preemptRunner;
168 }
InlineFunctionRunner * preemptRunner_
bool folly::fibers::FiberManager::shouldRunLoopRemote ( )
inline

This should only be called by a LoopController.

Definition at line 262 of file FiberManagerInternal-inl.h.

References remoteCount_, remoteReadyQueue_, and remoteTaskQueue_.

Referenced by folly::fibers::SimpleLoopController::runLoop(), folly::fibers::ExecutorLoopController::scheduleThreadSafe(), and folly::fibers::EventBaseLoopController::scheduleThreadSafe().

262  {
263  --remoteCount_;
264  return !remoteReadyQueue_.empty() || !remoteTaskQueue_.empty();
265 }
folly::AtomicIntrusiveLinkedList< Fiber,&Fiber::nextRemoteReady_ > remoteReadyQueue_
folly::AtomicIntrusiveLinkedList< RemoteTask,&RemoteTask::nextRemoteTask > remoteTaskQueue_
size_t folly::fibers::FiberManager::stackHighWatermark ( ) const
Returns
What was the most observed fiber stack usage (in bytes).

Definition at line 145 of file FiberManager.cpp.

References stackHighWatermark_.

Referenced by TEST().

145  {
146  return stackHighWatermark_;
147 }
void folly::fibers::FiberManager::yield ( )
inline

Yield execution of the currently running fiber. Must only be called from a fiber executing on this FiberManager. The calling fiber will be scheduled when all other fibers have had a chance to run and the event loop is serviced.

Definition at line 496 of file FiberManagerInternal-inl.h.

References activeFiber_, currentFiberManager_, folly::fibers::Fiber::preempt(), folly::fibers::Fiber::RUNNING, folly::fibers::Fiber::state_, and folly::fibers::Fiber::YIELDED.

Referenced by AtomicBatchDispatcherTesting::Job::preprocess(), and TEST().

496  {
497  assert(currentFiberManager_ == this);
498  assert(activeFiber_ != nullptr);
499  assert(activeFiber_->state_ == Fiber::RUNNING);
501 }
static FOLLY_TLS FiberManager * currentFiberManager_
void preempt(State state)
Definition: Fiber.cpp:172

Friends And Related Function Documentation

friend class Baton
friend

Definition at line 345 of file FiberManagerInternal.h.

friend class Fiber
friend

Definition at line 346 of file FiberManagerInternal.h.

Referenced by getFiber().

Member Data Documentation

Fiber* folly::fibers::FiberManager::activeFiber_ {nullptr}
private
GlobalFiberTailQueue folly::fibers::FiberManager::allFibers_
private

list of all Fiber objects owned

Definition at line 386 of file FiberManagerInternal.h.

Referenced by folly::fibers::Fiber::Fiber().

bool folly::fibers::FiberManager::alternateSignalStackRegistered_ {false}
private

Definition at line 508 of file FiberManagerInternal.h.

Referenced by loopUntilNoReadyImpl(), and registerAlternateSignalStack().

folly::Function<void(Fiber&)> folly::fibers::FiberManager::awaitFunc_
private

Function passed to the await call.

Definition at line 439 of file FiberManagerInternal.h.

Referenced by runReadyFiber(), and folly::fibers::Baton::waitFiber().

Fiber* folly::fibers::FiberManager::currentFiber_ {nullptr}
private

Same as active fiber, but also set for functions run from fiber on main context.

Definition at line 379 of file FiberManagerInternal.h.

Referenced by local(), and runReadyFiber().

FOLLY_TLS FiberManager * folly::fibers::FiberManager::currentFiberManager_ = nullptr
staticprivate

When we are inside FiberManager loop this points to FiberManager. Otherwise it's nullptr

Definition at line 406 of file FiberManagerInternal.h.

Referenced by getFiberManager(), getFiberManagerUnsafe(), loopUntilNoReadyImpl(), and yield().

ExceptionCallback folly::fibers::FiberManager::exceptionCallback_
private

task exception callback

Definition at line 456 of file FiberManagerInternal.h.

Referenced by folly::fibers::Fiber::fiberFunc(), runReadyFiber(), and setExceptionCallback().

size_t folly::fibers::FiberManager::fiberId_ {0}
private

id of last fiber used

Definition at line 391 of file FiberManagerInternal.h.

Referenced by getFiber().

size_t folly::fibers::FiberManager::fibersActive_ {0}
private

number of running or blocked fibers

Definition at line 390 of file FiberManagerInternal.h.

Referenced by doFibersPoolResizing(), getFiber(), hasTasks(), runReadyFiber(), and ~FiberManager().

size_t folly::fibers::FiberManager::fibersAllocated_ {0}
private

total number of fibers allocated

Definition at line 388 of file FiberManagerInternal.h.

Referenced by doFibersPoolResizing(), fibersAllocated(), getFiber(), and runReadyFiber().

FiberTailQueue folly::fibers::FiberManager::fibersPool_
private

pool of uninitialized Fiber objects

Definition at line 384 of file FiberManagerInternal.h.

Referenced by doFibersPoolResizing(), getFiber(), runReadyFiber(), and ~FiberManager().

FibersPoolResizer folly::fibers::FiberManager::fibersPoolResizer_
private

Definition at line 476 of file FiberManagerInternal.h.

Referenced by FiberManager(), and getFiber().

bool folly::fibers::FiberManager::fibersPoolResizerScheduled_ {false}
private

Definition at line 477 of file FiberManagerInternal.h.

Referenced by getFiber().

size_t folly::fibers::FiberManager::fibersPoolSize_ {0}
private

total number of fibers in the free pool

Definition at line 389 of file FiberManagerInternal.h.

Referenced by doFibersPoolResizing(), fibersPoolSize(), getFiber(), and runReadyFiber().

folly::Function<void()> folly::fibers::FiberManager::immediateFunc_
private

Function passed to the runInMainContext call.

Definition at line 444 of file FiberManagerInternal.h.

Referenced by runInMainContext(), and runReadyFiber().

bool folly::fibers::FiberManager::isLoopScheduled_ {false}
private

was the ready loop scheduled to run?

Definition at line 400 of file FiberManagerInternal.h.

Referenced by ensureLoopScheduled(), and loopUntilNoReadyImpl().

std::type_index folly::fibers::FiberManager::localType_
private

Only local of this type will be available for fibers.

Definition at line 484 of file FiberManagerInternal.h.

Referenced by addTaskRemote(), FiberManager(), initLocalData(), and local().

std::unique_ptr<LoopController> folly::fibers::FiberManager::loopController_
private
size_t folly::fibers::FiberManager::maxFibersActiveLastPeriod_ {0}
private

Maximum number of active fibers in the last period lasting Options::fibersPoolResizePeriod milliseconds.

Definition at line 397 of file FiberManagerInternal.h.

Referenced by doFibersPoolResizing(), and getFiber().

ExecutionObserver* folly::fibers::FiberManager::observer_ {nullptr}
private
const Options folly::fibers::FiberManager::options_
private
InlineFunctionRunner* folly::fibers::FiberManager::preemptRunner_ {nullptr}
private

Preempt runner.

Definition at line 449 of file FiberManagerInternal.h.

Referenced by folly::fibers::Fiber::preempt(), and setPreemptRunner().

FiberTailQueue folly::fibers::FiberManager::readyFibers_
private

queue of fibers ready to be executed

Definition at line 381 of file FiberManagerInternal.h.

Referenced by addTask(), addTaskFinally(), hasReadyTasks(), loopUntilNoReadyImpl(), folly::fibers::Fiber::resume(), and ~FiberManager().

ssize_t folly::fibers::FiberManager::remoteCount_ {0}
private

Definition at line 464 of file FiberManagerInternal.h.

Referenced by hasTasks(), loopUntilNoReadyImpl(), and shouldRunLoopRemote().

folly::AtomicIntrusiveLinkedList<Fiber, &Fiber::nextRemoteReady_> folly::fibers::FiberManager::remoteReadyQueue_
private
folly::AtomicIntrusiveLinkedList<RemoteTask, &RemoteTask::nextRemoteTask> folly::fibers::FiberManager::remoteTaskQueue_
private
GuardPageAllocator folly::fibers::FiberManager::stackAllocator_
private

Allocator used to allocate stack for Fibers in the pool. Allocates stack on the stack of the main context.

Definition at line 412 of file FiberManagerInternal.h.

Referenced by folly::fibers::Fiber::~Fiber().

size_t folly::fibers::FiberManager::stackHighWatermark_ {0}
private

Largest observed individual Fiber stack usage in bytes.

Definition at line 419 of file FiberManagerInternal.h.

Referenced by folly::fibers::Fiber::fiberFunc(), folly::fibers::Fiber::recordStackPosition(), and stackHighWatermark().

std::shared_ptr<TimeoutController> folly::fibers::FiberManager::timeoutManager_
private

Definition at line 466 of file FiberManagerInternal.h.

Referenced by FiberManager().

FiberTailQueue folly::fibers::FiberManager::yieldedFibers_
private

queue of fibers which have yielded execution

Definition at line 382 of file FiberManagerInternal.h.

Referenced by loopUntilNoReadyImpl(), and runReadyFiber().


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