proxygen
|
#include <VirtualEventBase.h>
Protected Member Functions | |
bool | keepAliveAcquire () override |
void | keepAliveRelease () override |
Protected Member Functions inherited from folly::TimeoutManager | |
void | clearCobTimeouts () |
Private Types | |
using | LoopCallbackList = EventBase::LoopCallback::List |
Private Member Functions | |
ssize_t | keepAliveCount () |
std::future< void > | destroy () |
void | destroyImpl () |
Private Attributes | |
KeepAlive< EventBase > | evb_ |
ssize_t | loopKeepAliveCount_ {1} |
std::atomic< ssize_t > | loopKeepAliveCountAtomic_ {0} |
std::promise< void > | destroyPromise_ |
std::future< void > | destroyFuture_ {destroyPromise_.get_future()} |
KeepAlive< VirtualEventBase > | loopKeepAlive_ |
folly::Synchronized< LoopCallbackList > | onDestructionCallbacks_ |
Friends | |
class | EventBase |
Additional Inherited Members | |
Public Types inherited from folly::TimeoutManager | |
enum | InternalEnum { InternalEnum::INTERNAL, InternalEnum::NORMAL } |
typedef std::chrono::milliseconds | timeout_type |
using | Func = folly::Function< void()> |
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) |
VirtualEventBase implements a light-weight view onto existing EventBase.
Multiple VirtualEventBases can be backed by a single EventBase. Similarly to EventBase, VirtualEventBase implements loopKeepAlive() functionality, which allows callbacks holding KeepAlive token to keep EventBase looping until they are complete.
VirtualEventBase destructor blocks until all its KeepAliveTokens are released and all tasks scheduled through it are complete. EventBase destructor also blocks until all VirtualEventBases backed by it are released.
Definition at line 40 of file VirtualEventBase.h.
Definition at line 161 of file VirtualEventBase.h.
|
explicit |
Definition at line 20 of file VirtualEventBase.cpp.
|
delete |
|
override |
Definition at line 57 of file VirtualEventBase.cpp.
References destroy(), destroyFuture_, and evb_.
|
inlineoverridevirtual |
Implements folly::Executor.
Definition at line 115 of file VirtualEventBase.h.
References folly::gen::move, and runInEventBaseThread().
|
inlineoverridevirtual |
Attaches/detaches TimeoutManager to AsyncTimeout
Implements folly::TimeoutManager.
Definition at line 85 of file VirtualEventBase.h.
References evb_.
|
inlineoverridevirtual |
This is used to mark the beginning of a new loop cycle by the first handler fired within that cycle.
Implements folly::TimeoutManager.
Definition at line 104 of file VirtualEventBase.h.
References evb_.
|
inlineoverridevirtual |
Cancels the AsyncTimeout, if scheduled
Implements folly::TimeoutManager.
Definition at line 100 of file VirtualEventBase.h.
References evb_.
|
private |
Definition at line 23 of file VirtualEventBase.cpp.
References destroyFuture_, evb_, and folly::gen::move.
Referenced by keepAliveCount(), and ~VirtualEventBase().
|
private |
Definition at line 29 of file VirtualEventBase.cpp.
References folly::TimeoutManager::clearCobTimeouts(), destroyPromise_, evb_, onDestructionCallbacks_, SCOPE_EXIT, and folly::Synchronized< T, Mutex >::swap().
Referenced by keepAliveCount(), and keepAliveRelease().
|
inlineoverridevirtual |
Implements folly::TimeoutManager.
Definition at line 91 of file VirtualEventBase.h.
References evb_.
|
inline |
Definition at line 49 of file VirtualEventBase.h.
References evb_, and runOnDestruction().
Referenced by folly::fibers::EventBaseLoopController::schedule(), and TEST_F().
|
inline |
|
inlineoverridevirtual |
Helper method to know whether we are running in the timeout manager thread
Implements folly::TimeoutManager.
Definition at line 108 of file VirtualEventBase.h.
References evb_.
|
inlineoverrideprotectedvirtual |
Reimplemented from folly::Executor.
Definition at line 124 of file VirtualEventBase.h.
References evb_, loopKeepAliveCount_, and loopKeepAliveCountAtomic_.
|
inlineprivate |
Definition at line 151 of file VirtualEventBase.h.
References destroy(), destroyImpl(), loopKeepAliveCount_, and loopKeepAliveCountAtomic_.
|
inlineoverrideprotectedvirtual |
Reimplemented from folly::Executor.
Definition at line 135 of file VirtualEventBase.h.
References destroyImpl(), evb_, loopKeepAliveCount_, and loopKeepAliveCountAtomic_.
|
delete |
|
inline |
VirtualEventBase destructor blocks until all tasks scheduled through its runInEventBaseThread are complete.
Definition at line 72 of file VirtualEventBase.h.
References evb_, f, and folly::Executor::getKeepAliveToken().
Referenced by add(), and folly::fibers::EventBaseLoopController::scheduleThreadSafe().
void folly::VirtualEventBase::runOnDestruction | ( | EventBase::LoopCallback * | callback | ) |
Adds the given callback to a queue of things run before destruction of current VirtualEventBase.
This allows users of VirtualEventBase that run in it, but don't control it, to be notified before VirtualEventBase gets destructed.
Note: this will be called from the loop of the EventBase, backing this VirtualEventBase
Definition at line 65 of file VirtualEventBase.cpp.
References folly::EventBase::LoopCallback::cancelLoopCallback(), and onDestructionCallbacks_.
Referenced by getEventBase().
|
inlineoverridevirtual |
Schedules AsyncTimeout to fire after timeout
milliseconds
Implements folly::TimeoutManager.
Definition at line 95 of file VirtualEventBase.h.
References evb_.
|
inline |
|
friend |
Definition at line 149 of file VirtualEventBase.h.
|
private |
Definition at line 168 of file VirtualEventBase.h.
Referenced by destroy(), and ~VirtualEventBase().
|
private |
Definition at line 167 of file VirtualEventBase.h.
Referenced by destroyImpl().
Definition at line 163 of file VirtualEventBase.h.
Referenced by attachTimeoutManager(), bumpHandlingTime(), cancelTimeout(), destroy(), destroyImpl(), detachTimeoutManager(), getEventBase(), inRunningEventBaseThread(), isInTimeoutManagerThread(), keepAliveAcquire(), keepAliveRelease(), runInEventBaseThread(), scheduleTimeout(), timer(), and ~VirtualEventBase().
|
private |
Definition at line 169 of file VirtualEventBase.h.
|
private |
Definition at line 165 of file VirtualEventBase.h.
Referenced by keepAliveAcquire(), keepAliveCount(), and keepAliveRelease().
|
private |
Definition at line 166 of file VirtualEventBase.h.
Referenced by keepAliveAcquire(), keepAliveCount(), and keepAliveRelease().
|
private |
Definition at line 172 of file VirtualEventBase.h.
Referenced by destroyImpl(), and runOnDestruction().