proxygen
folly::python::AsyncioExecutor Class Reference

#include <AsyncioExecutor.h>

Inheritance diagram for folly::python::AsyncioExecutor:
folly::DrivableExecutor folly::SequencedExecutor folly::Executor folly::Executor

Public Types

using Func = folly::Func
 

Public Member Functions

 ~AsyncioExecutor () override
 
void add (Func func) override
 
int fileno () const
 
void drive () noexceptoverride
 
- Public Member Functions inherited from folly::DrivableExecutor
 ~DrivableExecutor () override=default
 
- Public Member Functions inherited from folly::Executor
virtual ~Executor ()
 
virtual void addWithPriority (Func, int8_t priority)
 
virtual uint8_t getNumPriorities () const
 

Protected Member Functions

bool keepAliveAcquire () override
 
void keepAliveRelease () override
 

Private Attributes

folly::NotificationQueue< Funcqueue_
 
folly::NotificationQueue< Func >::SimpleConsumer consumer_ {queue_}
 
std::atomic< size_t > keepAliveCounter_ {1}
 

Additional Inherited Members

- 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)
 
- 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
 
- 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

Definition at line 27 of file AsyncioExecutor.h.

Member Typedef Documentation

Constructor & Destructor Documentation

folly::python::AsyncioExecutor::~AsyncioExecutor ( )
inlineoverride

Definition at line 31 of file AsyncioExecutor.h.

References drive(), keepAliveCounter_, and keepAliveRelease().

31  {
33  while (keepAliveCounter_ > 0) {
34  drive();
35  }
36  }
std::atomic< size_t > keepAliveCounter_
void drive() noexceptoverride

Member Function Documentation

void folly::python::AsyncioExecutor::add ( Func  )
inlineoverridevirtual

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

Implements folly::Executor.

Definition at line 38 of file AsyncioExecutor.h.

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

38  {
39  queue_.putMessage(std::move(func));
40  }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
folly::NotificationQueue< Func > queue_
void folly::python::AsyncioExecutor::drive ( )
inlineoverridevirtualnoexcept

Implements folly::DrivableExecutor.

Definition at line 46 of file AsyncioExecutor.h.

References consumer_, and folly::exceptionStr().

Referenced by ~AsyncioExecutor().

46  {
47  consumer_.consumeUntilDrained([](Func&& func) {
48  try {
49  func();
50  } catch (...) {
51  LOG(ERROR) << "Exception thrown by NotificationQueueExecutor task."
52  << "Exception message: "
53  << folly::exceptionStr(std::current_exception());
54  }
55  });
56  }
fbstring exceptionStr(const std::exception &e)
folly::NotificationQueue< Func >::SimpleConsumer consumer_
int folly::python::AsyncioExecutor::fileno ( ) const
inline

Definition at line 42 of file AsyncioExecutor.h.

References consumer_.

42  {
43  return consumer_.getFd();
44  }
folly::NotificationQueue< Func >::SimpleConsumer consumer_
bool folly::python::AsyncioExecutor::keepAliveAcquire ( )
inlineoverrideprotectedvirtual

Reimplemented from folly::Executor.

Definition at line 59 of file AsyncioExecutor.h.

References keepAliveCounter_.

59  {
60  auto keepAliveCounter =
61  keepAliveCounter_.fetch_add(1, std::memory_order_relaxed);
62  // We should never increment from 0
63  DCHECK(keepAliveCounter > 0);
64  return true;
65  }
std::atomic< size_t > keepAliveCounter_
void folly::python::AsyncioExecutor::keepAliveRelease ( )
inlineoverrideprotectedvirtual

Reimplemented from folly::Executor.

Definition at line 67 of file AsyncioExecutor.h.

References keepAliveCounter_.

Referenced by ~AsyncioExecutor().

67  {
68  auto keepAliveCounter = --keepAliveCounter_;
69  DCHECK(keepAliveCounter >= 0);
70  }
std::atomic< size_t > keepAliveCounter_

Member Data Documentation

folly::NotificationQueue<Func>::SimpleConsumer folly::python::AsyncioExecutor::consumer_ {queue_}
private

Definition at line 74 of file AsyncioExecutor.h.

Referenced by drive(), and fileno().

std::atomic<size_t> folly::python::AsyncioExecutor::keepAliveCounter_ {1}
private

Definition at line 75 of file AsyncioExecutor.h.

Referenced by keepAliveAcquire(), keepAliveRelease(), and ~AsyncioExecutor().

folly::NotificationQueue<Func> folly::python::AsyncioExecutor::queue_
private

Definition at line 73 of file AsyncioExecutor.h.

Referenced by add().


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