proxygen
folly::QueuedImmediateExecutor Class Reference

#include <QueuedImmediateExecutor.h>

Inheritance diagram for folly::QueuedImmediateExecutor:
folly::Executor

Public Member Functions

void add (Func func) override
 
- 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

static QueuedImmediateExecutorinstance ()
 
- 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 Attributes

folly::ThreadLocal< std::queue< Func > > q_
 

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

Runs inline like InlineExecutor, but with a queue so that any tasks added to this executor by one of its own callbacks will be queued instead of executed inline (nested). This is usually better behavior than Inline.

Definition at line 31 of file QueuedImmediateExecutor.h.

Member Function Documentation

void folly::QueuedImmediateExecutor::add ( Func  )
overridevirtual

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

Implements folly::Executor.

Definition at line 28 of file QueuedImmediateExecutor.cpp.

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

Referenced by TEST().

28  {
29  auto& q = *q_;
30  q.push(std::move(callback));
31  if (q.size() == 1) {
32  while (!q.empty()) {
33  q.front()();
34  q.pop();
35  }
36  }
37 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
folly::ThreadLocal< std::queue< Func > > q_
QueuedImmediateExecutor & folly::QueuedImmediateExecutor::instance ( )
static

Definition at line 23 of file QueuedImmediateExecutor.cpp.

Referenced by folly::window().

23  {
24  static auto instance = Indestructible<QueuedImmediateExecutor>{};
25  return *instance;
26 }
static QueuedImmediateExecutor & instance()

Member Data Documentation

folly::ThreadLocal<std::queue<Func> > folly::QueuedImmediateExecutor::q_
private

Definition at line 38 of file QueuedImmediateExecutor.h.

Referenced by add().


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