proxygen
folly::fibers Namespace Reference

Namespaces

 detail
 

Classes

class  ABDCommitNotCalledException
 
class  ABDTokenNotDispatchedException
 
class  ABDUsageException
 
class  AtomicBatchDispatcher
 
class  BatchDispatcher
 
class  Baton
 
class  CacheManager
 
class  EventBaseLoopController
 
class  ExecutorLoopController
 
class  Fiber
 Fiber object used by FiberManager to execute tasks. More...
 
class  FiberImpl
 
class  FiberManager
 Single-threaded task execution engine. More...
 
struct  FirstArgOf
 
struct  FirstArgOf< F, typename std::enable_if< std::is_class< F >::value >::type >
 
struct  FirstArgOf< F, typename std::enable_if<!std::is_class< F >::value >::type >
 
class  GuardPageAllocator
 
class  InlineFunctionRunner
 
struct  IsRvalueRefTry
 
struct  IsRvalueRefTry< folly::Try< T > && >
 
class  LocalType
 
class  LoopController
 
class  Promise
 
class  Semaphore
 
class  SimpleLoopController
 
class  StackCache
 
class  StackCacheEntry
 
class  TaskIterator
 
class  TimedMutex
 
class  TimedRWMutex
 
class  TimeoutController
 

Typedefs

using once_flag = basic_once_flag< TimedMutex >
 
typedef Baton GenericBaton
 

Functions

template<class InputIterator >
TaskIterator< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type > > addTasks (InputIterator first, InputIterator last)
 
template<typename InputT , typename ResultT >
AtomicBatchDispatcher< InputT, ResultT > createAtomicBatchDispatcher (folly::Function< std::vector< ResultT >(std::vector< InputT > &&)> dispatchFunc, size_t initialCapacity)
 
template<typename F >
FirstArgOf< F >::type::value_type await (F &&func)
 
bool onFiber ()
 
template<typename F >
void addTask (F &&func)
 
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 ()
 
void yield ()
 
FiberManagergetFiberManager (EventBase &evb, const FiberManager::Options &opts)
 
FiberManagergetFiberManager (VirtualEventBase &evb, const FiberManager::Options &opts)
 
template<class InputIterator , class F >
void forEach (InputIterator first, InputIterator last, F &&f)
 
template<class InputIterator >
std::vector< typename std::enable_if< !std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, typename std::pair< size_t, invoke_result_t< typename std::iterator_traits< InputIterator >::value_type > > >::typecollectN (InputIterator first, InputIterator last, size_t n)
 
template<class InputIterator >
std::enable_if< std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, std::vector< size_t > >::type collectN (InputIterator first, InputIterator last, size_t n)
 
template<class InputIterator >
std::vector< typename std::enable_if< !std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, invoke_result_t< typename std::iterator_traits< InputIterator >::value_type > >::typecollectAll (InputIterator first, InputIterator last)
 
template<class InputIterator >
std::enable_if< std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, void >::type collectAll (InputIterator first, InputIterator last)
 
template<class InputIterator >
std::enable_if< !std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, typename std::pair< size_t, invoke_result_t< typename std::iterator_traits< InputIterator >::value_type > > >::type collectAny (InputIterator first, InputIterator last)
 
template<class InputIterator >
std::enable_if< std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, size_t >::type collectAny (InputIterator first, InputIterator last)
 

Variables

constexpr size_t kNumGuarded = 100
 
constexpr size_t kMaxInUse = 100
 

Typedef Documentation

Definition at line 25 of file GenericBaton.h.

Definition at line 23 of file CallOnce.h.

Function Documentation

template<typename F >
void folly::fibers::addTask ( F &&  func)
inline

Add a new task to be executed.

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

Definition at line 529 of file FiberManagerInternal.h.

References folly::fibers::FiberManager::addTask(), and folly::fibers::FiberManager::getFiberManager().

Referenced by collectN(), forEach(), TEST(), and testFiberLocal().

529  {
530  return FiberManager::getFiberManager().addTask(std::forward<F>(func));
531 }
FiberManager & getFiberManager(EventBase &evb, const FiberManager::Options &opts)
template<typename F , typename G >
void folly::fibers::addTaskFinally ( F &&  func,
G &&  finally 
)
inline

Add a new task. When the task is complete, execute finally(Try<Result>&&) on the main context. Task functor is run and destroyed on the fiber context. Finally functor is run and destroyed 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 545 of file FiberManagerInternal.h.

References folly::fibers::FiberManager::addTaskFinally(), await(), and folly::fibers::FiberManager::getFiberManager().

Referenced by folly::fibers::FiberManager::add(), and folly::fibers::FiberManager::addTaskFuture().

545  {
547  std::forward<F>(func), std::forward<G>(finally));
548 }
void addTaskFinally(F &&func, G &&finally)
FiberManager & getFiberManager(EventBase &evb, const FiberManager::Options &opts)
template<class InputIterator >
TaskIterator< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type > > folly::fibers::addTasks ( InputIterator  first,
InputIterator  last 
)
inline

Schedules several tasks and immediately returns an iterator, that allow one to traverse tasks in the order of their completion. All results and exceptions thrown are stored alongside with the task id and are accessible via iterator.

Parameters
firstRange of tasks to be scheduled
last
Returns
movable, non-copyable iterator

Definition at line 114 of file AddTasks-inl.h.

References folly::fibers::TaskIterator< T >::addTask(), folly::gen::first, and folly::gen::move.

Referenced by TEST().

114  {
115  typedef invoke_result_t<
116  typename std::iterator_traits<InputIterator>::value_type>
117  ResultType;
118  typedef TaskIterator<ResultType> IteratorType;
119 
120  IteratorType iterator;
121 
122  for (; first != last; ++first) {
123  iterator.addTask(std::move(*first));
124  }
125 
126  iterator.context_->results.reserve(iterator.context_->totalTasks);
127 
128  return std::move(iterator);
129 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
decltype(folly::pushmi::invoke(std::declval< F >(), std::declval< As >()...)) invoke_result_t
Definition: functional.h:47
constexpr detail::First first
Definition: Base-inl.h:2553
template<typename F >
FirstArgOf< F >::type::value_type folly::fibers::await ( F &&  func)
inline

Blocks task execution until given promise is fulfilled.

Calls function passing in a Promise<T>, which has to be fulfilled.

Returns
data which was used to fulfill the promise.

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

References folly::fibers::Promise< T, BatonT >::await().

Referenced by addTaskFinally(), collectN(), Application::loop(), folly::fibers::TaskIterator< T >::reserve(), runBenchmark(), and TEST().

557  {
558  typedef typename FirstArgOf<F>::type::value_type Result;
559  typedef typename FirstArgOf<F>::type::baton_type BatonT;
560 
561  return Promise<Result, BatonT>::await(std::forward<F>(func));
562 }
FirstArgOf< F >::type::value_type await(F &&func)
template<class InputIterator >
std::vector< typename std::enable_if< !std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, invoke_result_t< typename std::iterator_traits< InputIterator >::value_type > >::type > folly::fibers::collectAll ( InputIterator  first,
InputIterator  last 
)
inline

Schedules several tasks and blocks until all of these tasks are completed. If any of the tasks throws an exception, this exception will be re-thrown, but only when all the tasks are complete. If several tasks throw exceptions one of them will be re-thrown.

Parameters
firstRange of tasks to be scheduled
last
Returns
vector of values returned by tasks

Definition at line 147 of file WhenN-inl.h.

References forEach(), i, folly::gen::move, order, and folly::value().

Referenced by fizz::sm::getCertificateRequest(), and TEST().

147  {
148  typedef invoke_result_t<
149  typename std::iterator_traits<InputIterator>::value_type>
150  Result;
151  size_t n = size_t(std::distance(first, last));
152  std::vector<Result> results;
153  std::vector<size_t> order(n);
154  results.reserve(n);
155 
156  forEach(first, last, [&results, &order](size_t id, Result result) {
157  order[id] = results.size();
158  results.emplace_back(std::move(result));
159  });
160  assert(results.size() == n);
161 
162  std::vector<Result> orderedResults;
163  orderedResults.reserve(n);
164 
165  for (size_t i = 0; i < n; ++i) {
166  orderedResults.emplace_back(std::move(results[order[i]]));
167  }
168 
169  return orderedResults;
170 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void forEach(InputIterator first, InputIterator last, F &&f)
Definition: ForEach-inl.h:41
decltype(folly::pushmi::invoke(std::declval< F >(), std::declval< As >()...)) invoke_result_t
Definition: functional.h:47
int order
constexpr detail::First first
Definition: Base-inl.h:2553
template<class InputIterator >
std::enable_if< std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, void >::type folly::fibers::collectAll ( InputIterator  first,
InputIterator  last 
)
inline

collectAll specialization for functions returning void

Parameters
firstRange of tasks to be scheduled
last

Definition at line 178 of file WhenN-inl.h.

References forEach(), type, and folly::value().

178  {
179  forEach(first, last, [](size_t /* id */) {});
180 }
void forEach(InputIterator first, InputIterator last, F &&f)
Definition: ForEach-inl.h:41
constexpr detail::First first
Definition: Base-inl.h:2553
template<class InputIterator >
std::enable_if< !std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, typename std::pair< size_t, invoke_result_t< typename std::iterator_traits< InputIterator >::value_type > > >::type folly::fibers::collectAny ( InputIterator  first,
InputIterator  last 
)
inline

Schedules several tasks and blocks until one of them is completed. If this task throws an exception, this exception will be re-thrown. Exceptions thrown by all other tasks will be ignored.

Parameters
firstRange of tasks to be scheduled
last
Returns
pair of index of the first completed task and its return value

Definition at line 192 of file WhenN-inl.h.

References collectN(), folly::gen::move, and folly::value().

Referenced by TEST(), and testFiberLocal().

192  {
193  auto result = collectN(first, last, 1);
194  assert(result.size() == 1);
195  return std::move(result[0]);
196 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::enable_if< std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, std::vector< size_t > >::type collectN(InputIterator first, InputIterator last, size_t n)
Definition: WhenN-inl.h:91
constexpr detail::First first
Definition: Base-inl.h:2553
template<class InputIterator >
std::enable_if< std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, size_t >::type folly::fibers::collectAny ( InputIterator  first,
InputIterator  last 
)
inline

WhenAny specialization for functions returning void.

Parameters
firstRange of tasks to be scheduled
last
Returns
index of the first completed task

Definition at line 204 of file WhenN-inl.h.

References collectN(), and folly::gen::move.

204  {
205  auto result = collectN(first, last, 1);
206  assert(result.size() == 1);
207  return std::move(result[0]);
208 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
std::enable_if< std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, std::vector< size_t > >::type collectN(InputIterator first, InputIterator last, size_t n)
Definition: WhenN-inl.h:91
constexpr detail::First first
Definition: Base-inl.h:2553
template<class InputIterator >
std::vector< typename std::enable_if< !std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, typename std::pair< size_t, invoke_result_t< typename std::iterator_traits< InputIterator >::value_type > > >::type > folly::fibers::collectN ( InputIterator  first,
InputIterator  last,
size_t  n 
)
inline

Schedules several tasks and blocks until n of these tasks are completed. If any of these n tasks throws an exception, this exception will be re-thrown, but only when n tasks are complete. If several tasks throw exceptions one of them will be re-thrown.

Parameters
firstRange of tasks to be scheduled
last
nNumber of tasks to wait for
Returns
vector of pairs (task index, return value of task)

Definition at line 34 of file WhenN-inl.h.

References addTask(), await(), context, f, folly::gen::first, i, folly::gen::move, type, and folly::value().

Referenced by collectAny(), and TEST().

34  {
35  typedef invoke_result_t<
36  typename std::iterator_traits<InputIterator>::value_type>
37  Result;
38  assert(n > 0);
39  assert(std::distance(first, last) >= 0);
40  assert(n <= static_cast<size_t>(std::distance(first, last)));
41 
42  struct Context {
43  std::vector<std::pair<size_t, Result>> results;
44  size_t tasksTodo;
45  std::exception_ptr e;
47 
48  Context(size_t tasksTodo_) : tasksTodo(tasksTodo_) {
49  this->results.reserve(tasksTodo_);
50  }
51  };
52  auto context = std::make_shared<Context>(n);
53 
54  await([first, last, context](Promise<void> promise) mutable {
55  context->promise = std::move(promise);
56  for (size_t i = 0; first != last; ++i, ++first) {
57  addTask([i, context, f = std::move(*first)]() {
58  try {
59  auto result = f();
60  if (context->tasksTodo == 0) {
61  return;
62  }
63  context->results.emplace_back(i, std::move(result));
64  } catch (...) {
65  if (context->tasksTodo == 0) {
66  return;
67  }
68  context->e = std::current_exception();
69  }
70  if (--context->tasksTodo == 0) {
71  context->promise->setValue();
72  }
73  });
74  }
75  });
76 
77  if (context->e != std::exception_ptr()) {
79  }
80 
81  return std::move(context->results);
82 }
auto f
void rethrow_exception(std::exception_ptr ep)
context
Definition: CMakeCache.txt:563
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void addTask(F &&func)
decltype(folly::pushmi::invoke(std::declval< F >(), std::declval< As >()...)) invoke_result_t
Definition: functional.h:47
constexpr detail::First first
Definition: Base-inl.h:2553
FirstArgOf< F >::type::value_type await(F &&func)
template<class InputIterator >
std::enable_if< std::is_same< invoke_result_t< typename std::iterator_traits< InputIterator >::value_type >, void >::value, std::vector< size_t > >::type folly::fibers::collectN ( InputIterator  first,
InputIterator  last,
size_t  n 
)
inline

collectN specialization for functions returning void

Parameters
firstRange of tasks to be scheduled
last
nNumber of tasks to wait for
Returns
vector of completed task indices

Definition at line 91 of file WhenN-inl.h.

References addTask(), await(), context, f, folly::gen::first, i, folly::gen::move, type, and folly::value().

91  {
92  assert(n > 0);
93  assert(std::distance(first, last) >= 0);
94  assert(n <= static_cast<size_t>(std::distance(first, last)));
95 
96  struct Context {
97  std::vector<size_t> taskIndices;
98  std::exception_ptr e;
99  size_t tasksTodo;
101 
102  Context(size_t tasksTodo_) : tasksTodo(tasksTodo_) {
103  this->taskIndices.reserve(tasksTodo_);
104  }
105  };
106  auto context = std::make_shared<Context>(n);
107 
108  await([first, last, context](Promise<void> promise) mutable {
109  context->promise = std::move(promise);
110  for (size_t i = 0; first != last; ++i, ++first) {
111  addTask([i, context, f = std::move(*first)]() {
112  try {
113  f();
114  if (context->tasksTodo == 0) {
115  return;
116  }
117  context->taskIndices.push_back(i);
118  } catch (...) {
119  if (context->tasksTodo == 0) {
120  return;
121  }
122  context->e = std::current_exception();
123  }
124  if (--context->tasksTodo == 0) {
125  context->promise->setValue();
126  }
127  });
128  }
129  });
130 
131  if (context->e != std::exception_ptr()) {
133  }
134 
135  return context->taskIndices;
136 }
auto f
void rethrow_exception(std::exception_ptr ep)
context
Definition: CMakeCache.txt:563
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void addTask(F &&func)
constexpr detail::First first
Definition: Base-inl.h:2553
FirstArgOf< F >::type::value_type await(F &&func)
template<typename InputT , typename ResultT >
AtomicBatchDispatcher< InputT, ResultT > folly::fibers::createAtomicBatchDispatcher ( folly::Function< std::vector< ResultT >(std::vector< InputT > &&)>  dispatchFunc,
size_t  initialCapacity 
)

Definition at line 214 of file AtomicBatchDispatcher-inl.h.

References folly::gen::move, and folly::fibers::AtomicBatchDispatcher< InputT, ResultT >::reserve().

Referenced by TEST().

216  {
217  auto abd = AtomicBatchDispatcher<InputT, ResultT>(std::move(dispatchFunc));
218  if (initialCapacity) {
219  abd.reserve(initialCapacity);
220  }
221  return abd;
222 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
template<class InputIterator , class F >
void folly::fibers::forEach ( InputIterator  first,
InputIterator  last,
F &&  f 
)
inline

Schedules several tasks and blocks until all of them are completed. In the process of their successfull completion given callback would be called for each of them with the index of the task and the result it returned (if not void). If any of these n tasks throws an exception, this exception will be re-thrown, but only when all tasks are complete. If several tasks throw exceptions one of them will be re-thrown. Callback won't be called for tasks that throw exception.

Parameters
firstRange of tasks to be scheduled
last
Fcallback to call for each result. In case of each task returning void it should be callable F(size_t id) otherwise should be callable F(size_t id, Result)

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

References addTask(), f, folly::gen::first, i, folly::gen::move, and folly::fibers::Baton::wait().

Referenced by collectAll(), and TEST().

41  {
42  if (first == last) {
43  return;
44  }
45 
46  typedef typename std::iterator_traits<InputIterator>::value_type FuncType;
47 
48  size_t tasksTodo = 1;
49  std::exception_ptr e;
50  Baton baton;
51 
52  auto taskFunc = [&tasksTodo, &e, &f, &baton](size_t id, FuncType&& func) {
53  return [id,
54  &tasksTodo,
55  &e,
56  &f,
57  &baton,
58  func_ = std::forward<FuncType>(func)]() mutable {
59  try {
60  callFuncs(std::forward<FuncType>(func_), f, id);
61  } catch (...) {
62  e = std::current_exception();
63  }
64  if (--tasksTodo == 0) {
65  baton.post();
66  }
67  };
68  };
69 
70  auto firstTask = first;
71  ++first;
72 
73  for (size_t i = 1; first != last; ++i, ++first, ++tasksTodo) {
74  addTask(taskFunc(i, std::move(*first)));
75  }
76 
77  taskFunc(0, std::move(*firstTask))();
78  baton.wait();
79 
80  if (e != std::exception_ptr()) {
82  }
83 }
auto f
void rethrow_exception(std::exception_ptr ep)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void addTask(F &&func)
constexpr detail::First first
Definition: Base-inl.h:2553
FiberManager & folly::fibers::getFiberManager ( EventBase evb,
const FiberManager::Options opts 
)

Definition at line 183 of file FiberManagerMap.cpp.

References folly::pushmi::operators::get.

Referenced by folly::FiberIOExecutor::add(), BENCHMARK(), main(), folly::fibers::FiberManager::runQueueSize(), TEST(), and TEST_F().

185  {
186  return ThreadLocalCache<EventBase>::get(evb, opts);
187 }
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
Definition: submit.h:391
FiberManager & folly::fibers::getFiberManager ( VirtualEventBase evb,
const FiberManager::Options opts 
)

Definition at line 189 of file FiberManagerMap.cpp.

References folly::pushmi::operators::get.

191  {
192  return ThreadLocalCache<VirtualEventBase>::get(evb, opts);
193 }
PUSHMI_INLINE_VAR constexpr detail::get_fn< T > get
Definition: submit.h:391
template<typename T >
T& folly::fibers::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 584 of file FiberManagerInternal.h.

References folly::fibers::FiberManager::getFiberManagerUnsafe(), and folly::T.

Referenced by folly::fibers::FiberManager::add(), lifo_test(), folly::atomic_shared_ptr< T, Atom, CountedDetail >::load(), folly::atomic_shared_ptr< T, Atom, CountedDetail >::putOwnedBase(), folly::detail::ThreadCachedLists< Tag >::ListHead::splice(), folly::atomic_shared_ptr< T, Atom, CountedDetail >::takeOwnedBase(), and folly::AsyncSocket::withAddr().

584  {
585  auto fm = FiberManager::getFiberManagerUnsafe();
586  if (fm) {
587  return fm->local<T>();
588  }
589  return FiberManager::localThread<T>();
590 }
#define T(v)
Definition: http_parser.c:233
bool folly::fibers::onFiber ( )
inline
Returns
true iff we are running in a fiber's context

Definition at line 517 of file FiberManagerInternal.h.

References folly::fibers::FiberManager::getFiberManagerUnsafe().

Referenced by wangle::SSLSessionCacheManager::getSession(), folly::fibers::TimedMutex::lockHelper(), and TEST_F().

517  {
518  auto fm = FiberManager::getFiberManagerUnsafe();
519  return fm ? fm->hasActiveFiber() : false;
520 }
template<typename F >
invoke_result_t<F> folly::fibers::runInMainContext ( F &&  func)
inline

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 568 of file FiberManagerInternal.h.

References folly::fibers::FiberManager::getFiberManagerUnsafe(), and UNLIKELY.

Referenced by folly::fibers::FiberManager::add(), folly::fibers::FiberManager::addTaskRemoteFuture(), folly::python::getFiberManager(), and TEST().

568  {
569  auto fm = FiberManager::getFiberManagerUnsafe();
570  if (UNLIKELY(fm == nullptr)) {
571  return func();
572  }
573  return fm->runInMainContext(std::forward<F>(func));
574 }
#define UNLIKELY(x)
Definition: Likely.h:48
void folly::fibers::yield ( )
inline

Definition at line 592 of file FiberManagerInternal.h.

References folly::fibers::FiberManager::getFiberManagerUnsafe().

Referenced by folly::SharedMutexImpl< true >::applyDeferredReaders(), folly::detail::atomic_hash_spin_wait(), atomicIncrBaseline(), BENCHMARK_RELATIVE(), ConcurrentFlowManySender::cancellation_test(), ConcurrentFlowSingleSender::cancellation_test(), contendedRW(), contendedUse(), contentionAtWidth(), folly::fibers::FiberManager::currentFiber(), folly::detail::LifoSemBase< BatonType, Atom >::decrOrPush(), folly::RelaxedConcurrentPriorityQueue< T, MayBlock, SupportsSize, PopBatch, ListTargetSize, Mutex, Atom >::grow(), folly::detail::LifoSemBase< BatonType, Atom >::incrOrPop(), folly::isSequencedExecutor(), liveClockWaitUntilTests(), folly::RWSpinLock::lock(), folly::detail::lock(), folly::RWSpinLock::lock_shared(), folly::RWSpinLock::lock_upgrade(), folly::MicroLockCore::lockSlowPath(), main(), FibYielder::operator()(), run_basic_tests(), runAllAndValidate(), runContendedReaders(), runMixed(), runPingPong(), runRemoteUnlock(), folly::detail::LifoSemBase< BatonType, Atom >::shutdown(), folly::detail::spin_yield_until(), folly::atomic_shared_ptr< T, Atom, CountedDetail >::takeOwnedBase(), TEST(), TEST_F(), folly::sync_tests::testConcurrency(), folly::detail::LifoSemBase< BatonType, Atom >::tryRemoveNode(), folly::RWSpinLock::unlock_upgrade_and_lock(), folly::hazptr_domain< DeterministicAtomic >::wait_for_zero_bulk_reclaims(), folly::EventBase::waitUntilRunning(), and folly::SharedMutexImpl< true >::yieldWaitForZeroBits().

592  {
593  auto fm = FiberManager::getFiberManagerUnsafe();
594  if (fm) {
595  fm->yield();
596  } else {
598  }
599 }

Variable Documentation

constexpr size_t folly::fibers::kMaxInUse = 100

Maximum number of allocator instances with guarded stacks enabled

Definition at line 53 of file GuardPageAllocator.cpp.

constexpr size_t folly::fibers::kNumGuarded = 100

Each stack with a guard page creates two memory mappings. Since this is a limited resource, we don't want to create too many of these.

The upper bound on total number of mappings created is kNumGuarded * kMaxInUse. Number of guarded stacks per allocator instance

Definition at line 48 of file GuardPageAllocator.cpp.

Referenced by folly::fibers::StackCache::giveBack(), and folly::fibers::StackCache::StackCache().