proxygen
|
#include <SimpleLoopController.h>
Public Member Functions | |
SimpleLoopController () | |
~SimpleLoopController () | |
void | setTimeFunc (Function< TimePoint()> timeFunc) |
template<typename F > | |
void | loop (F &&func) |
void | stop () |
int | remoteScheduleCalled () const |
void | runLoop () override |
void | schedule () override |
void | timedSchedule (std::function< void()> func, TimePoint time) override |
Public Member Functions inherited from folly::fibers::LoopController | |
virtual | ~LoopController () |
virtual void | timedSchedule (std::function< void()> func, TimePoint time)=0 |
Private Member Functions | |
void | setFiberManager (FiberManager *fm) override |
void | scheduleThreadSafe () override |
Private Attributes | |
FiberManager * | fm_ |
std::atomic< bool > | scheduled_ {false} |
bool | stopRequested_ |
std::atomic< int > | remoteScheduleCalled_ {0} |
int | remoteLoopRun_ {0} |
std::vector< std::pair< TimePoint, std::function< void()> > > | scheduledFuncs_ |
Function< TimePoint()> | timeFunc_ {[] { return Clock::now(); }} |
Friends | |
class | FiberManager |
Additional Inherited Members | |
Public Types inherited from folly::fibers::LoopController | |
typedef std::chrono::steady_clock | Clock |
typedef std::chrono::time_point< Clock > | TimePoint |
Definition at line 31 of file SimpleLoopController.h.
|
inline |
Definition at line 33 of file SimpleLoopController.h.
|
inline |
Definition at line 35 of file SimpleLoopController.h.
References scheduled_.
|
inline |
Run FiberManager loop; if no ready task are present, run provided function. Stops after both stop() has been called and no waiting tasks remain.
Definition at line 49 of file SimpleLoopController.h.
References folly::gen::first, fm_, folly::fibers::FiberManager::hasTasks(), i, LIKELY, runLoop(), scheduled_, scheduledFuncs_, stopRequested_, folly::swap(), folly::detail::distributed_mutex::time(), and timeFunc_.
Referenced by main().
|
inline |
Definition at line 82 of file SimpleLoopController.h.
References remoteScheduleCalled_.
|
inlineoverridevirtual |
Run FiberManager loopUntilNoReadyImpl(). May have additional logic specific to a LoopController.
Implements folly::fibers::LoopController.
Definition at line 86 of file SimpleLoopController.h.
References fm_, folly::fibers::FiberManager::loopUntilNoReadyImpl(), remoteLoopRun_, remoteScheduleCalled_, and folly::fibers::FiberManager::shouldRunLoopRemote().
Referenced by loop().
|
inlineoverridevirtual |
Called by FiberManager to schedule the loop function run at some point in the futufre.
Implements folly::fibers::LoopController.
Definition at line 100 of file SimpleLoopController.h.
References scheduled_.
|
inlineoverrideprivatevirtual |
Same as schedule(), but safe to call from any thread.
Implements folly::fibers::LoopController.
Definition at line 123 of file SimpleLoopController.h.
References remoteScheduleCalled_, and scheduled_.
|
inlineoverrideprivatevirtual |
Called by FiberManager to associate itself with the LoopController.
Implements folly::fibers::LoopController.
Definition at line 119 of file SimpleLoopController.h.
Definition at line 39 of file SimpleLoopController.h.
References folly::gen::move, and timeFunc_.
|
inline |
Requests exit from loop() as soon as all waiting tasks complete.
Definition at line 78 of file SimpleLoopController.h.
References stopRequested_.
Referenced by Application::loop().
|
inlineoverride |
Definition at line 104 of file SimpleLoopController.h.
References folly::gen::move, and scheduledFuncs_.
|
friend |
Definition at line 128 of file SimpleLoopController.h.
|
private |
Definition at line 109 of file SimpleLoopController.h.
|
private |
Definition at line 113 of file SimpleLoopController.h.
Referenced by runLoop().
|
private |
Definition at line 112 of file SimpleLoopController.h.
Referenced by remoteScheduleCalled(), runLoop(), and scheduleThreadSafe().
|
private |
Definition at line 110 of file SimpleLoopController.h.
Referenced by loop(), schedule(), scheduleThreadSafe(), and ~SimpleLoopController().
|
private |
Definition at line 114 of file SimpleLoopController.h.
Referenced by loop(), and timedSchedule().
|
private |
Definition at line 111 of file SimpleLoopController.h.
|
private |
Definition at line 115 of file SimpleLoopController.h.
Referenced by loop(), and setTimeFunc().