proxygen
|
#include <IOThreadPoolExecutor.h>
Classes | |
struct | IOThread |
Public Member Functions | |
IOThreadPoolExecutor (size_t numThreads, std::shared_ptr< ThreadFactory > threadFactory=std::make_shared< NamedThreadFactory >("IOThreadPool"), folly::EventBaseManager *ebm=folly::EventBaseManager::get(), bool waitForAll=false) | |
~IOThreadPoolExecutor () override | |
void | add (Func func) override |
void | add (Func func, std::chrono::milliseconds expiration, Func expireCallback=nullptr) override |
folly::EventBase * | getEventBase () override |
folly::EventBaseManager * | getEventBaseManager () |
![]() | |
ThreadPoolExecutor (size_t maxThreads, size_t minThreads, std::shared_ptr< ThreadFactory > threadFactory, bool isWaitForAll=false) | |
~ThreadPoolExecutor () override | |
void | setThreadFactory (std::shared_ptr< ThreadFactory > threadFactory) |
std::shared_ptr< ThreadFactory > | getThreadFactory () |
size_t | numThreads () |
void | setNumThreads (size_t numThreads) |
size_t | numActiveThreads () |
void | stop () |
void | join () |
PoolStats | getPoolStats () |
size_t | getPendingTaskCount () |
std::string | getName () |
void | subscribeToTaskStats (TaskStatsCallback cb) |
void | addObserver (std::shared_ptr< Observer >) |
void | removeObserver (std::shared_ptr< Observer >) |
void | setThreadDeathTimeout (std::chrono::milliseconds timeout) |
![]() | |
DefaultKeepAliveExecutor () | |
virtual | ~DefaultKeepAliveExecutor () |
folly::Executor::KeepAlive | weakRef () |
![]() | |
virtual | ~Executor () |
virtual void | addWithPriority (Func, int8_t priority) |
virtual uint8_t | getNumPriorities () const |
![]() | |
~IOExecutor () override=default | |
Static Public Member Functions | |
static folly::EventBase * | getEventBase (ThreadPoolExecutor::ThreadHandle *) |
![]() | |
static void | withAll (FunctionRef< void(ThreadPoolExecutor &)> f) |
![]() | |
template<typename ExecutorT > | |
static KeepAlive< ExecutorT > | getKeepAliveToken (ExecutorT *executor) |
template<typename ExecutorT > | |
static KeepAlive< ExecutorT > | getKeepAliveToken (ExecutorT &executor) |
Private Member Functions | |
ThreadPtr | makeThread () override |
std::shared_ptr< IOThread > | pickThread () |
void | threadRun (ThreadPtr thread) override |
void | stopThreads (size_t n) override |
size_t | getPendingTaskCountImpl () override |
Private Attributes | |
std::atomic< size_t > | nextThread_ |
folly::ThreadLocal< std::shared_ptr< IOThread > > | thisThread_ |
folly::EventBaseManager * | eventBaseManager_ |
Additional Inherited Members | |
![]() | |
using | TaskStatsCallback = std::function< void(TaskStats)> |
![]() | |
static const int8_t | LO_PRI = SCHAR_MIN |
static const int8_t | MID_PRI = 0 |
static const int8_t | HI_PRI = SCHAR_MAX |
![]() | |
typedef std::shared_ptr< Thread > | ThreadPtr |
![]() | |
void | addThreads (size_t n) |
void | removeThreads (size_t n, bool isJoin) |
void | joinStoppedThreads (size_t n) |
void | ensureActiveThreads () |
void | ensureJoined () |
bool | minActive () |
bool | tryTimeoutThread () |
void | joinKeepAliveOnce () |
![]() | |
void | joinKeepAlive () |
![]() | |
static void | runTask (const ThreadPtr &thread, Task &&task) |
![]() | |
template<typename ExecutorT > | |
static bool | isKeepAliveDummy (const KeepAlive< ExecutorT > &keepAlive) |
template<typename ExecutorT > | |
static KeepAlive< ExecutorT > | makeKeepAlive (ExecutorT *executor) |
![]() | |
std::shared_ptr< ThreadFactory > | threadFactory_ |
const bool | isWaitForAll_ |
ThreadList | threadList_ |
SharedMutex | threadListLock_ |
StoppedThreadQueue | stoppedThreads_ |
std::atomic< bool > | isJoin_ {false} |
std::shared_ptr< TaskStatsCallbackRegistry > | taskStatsCallbacks_ |
std::vector< std::shared_ptr< Observer > > | observers_ |
folly::ThreadPoolListHook | threadPoolHook_ |
std::atomic< size_t > | maxThreads_ {0} |
std::atomic< size_t > | minThreads_ {0} |
std::atomic< size_t > | activeThreads_ {0} |
std::atomic< size_t > | threadsToJoin_ {0} |
std::chrono::milliseconds | threadTimeout_ {0} |
bool | keepAliveJoined_ {false} |
A Thread Pool for IO bound tasks
Definition at line 52 of file IOThreadPoolExecutor.h.
|
explicit |
Definition at line 70 of file IOThreadPoolExecutor.cpp.
References folly::ThreadPoolExecutor::setNumThreads().
|
override |
Definition at line 85 of file IOThreadPoolExecutor.cpp.
References folly::ThreadPoolExecutor::stop().
|
overridevirtual |
Enqueue a function to executed by this executor. This and all variants must be threadsafe.
Implements folly::ThreadPoolExecutor.
Definition at line 89 of file IOThreadPoolExecutor.cpp.
References folly::gen::move.
Referenced by destroy< IOThreadPoolExecutor >(), and stop< IOThreadPoolExecutor >().
|
overridevirtual |
Implements folly::ThreadPoolExecutor.
Definition at line 93 of file IOThreadPoolExecutor.cpp.
References folly::ThreadPoolExecutor::ensureActiveThreads(), folly::ThreadPoolExecutor::ThreadList::get(), folly::gen::move, pickThread(), folly::ThreadPoolExecutor::runTask(), folly::ThreadPoolExecutor::threadList_, and folly::ThreadPoolExecutor::threadListLock_.
|
overridevirtual |
Implements folly::IOExecutor.
Definition at line 144 of file IOThreadPoolExecutor.cpp.
References folly::ThreadPoolExecutor::ensureActiveThreads(), pickThread(), and folly::ThreadPoolExecutor::threadListLock_.
Referenced by wangle::ServerWorkerPool::threadStarted().
|
static |
Definition at line 150 of file IOThreadPoolExecutor.cpp.
References folly::IOThreadPoolExecutor::IOThread::eventBase, and h.
EventBaseManager * folly::IOThreadPoolExecutor::getEventBaseManager | ( | ) |
Definition at line 161 of file IOThreadPoolExecutor.cpp.
References eventBaseManager_.
|
overrideprivatevirtual |
Implements folly::ThreadPoolExecutor.
Definition at line 225 of file IOThreadPoolExecutor.cpp.
References count, folly::ThreadPoolExecutor::ThreadList::get(), folly::IOThreadPoolExecutor::IOThread::pendingTasks, and folly::ThreadPoolExecutor::threadList_.
|
overrideprivatevirtual |
Reimplemented from folly::ThreadPoolExecutor.
Definition at line 165 of file IOThreadPoolExecutor.cpp.
|
private |
Definition at line 118 of file IOThreadPoolExecutor.cpp.
References folly::ThreadPoolExecutor::ThreadList::get(), nextThread_, thisThread_, and folly::ThreadPoolExecutor::threadList_.
Referenced by add(), and getEventBase().
|
overrideprivatevirtual |
Implements folly::ThreadPoolExecutor.
Definition at line 202 of file IOThreadPoolExecutor.cpp.
References folly::ThreadPoolExecutor::StoppedThreadQueue::add(), folly::ThreadPoolExecutor::ThreadList::get(), folly::gen::guard(), i, folly::ThreadPoolExecutor::observers_, folly::ThreadPoolExecutor::ThreadList::remove(), folly::IOThreadPoolExecutor::IOThread::shouldRun, folly::ThreadPoolExecutor::stoppedThreads_, and folly::ThreadPoolExecutor::threadList_.
|
overrideprivatevirtual |
Implements folly::ThreadPoolExecutor.
Definition at line 169 of file IOThreadPoolExecutor.cpp.
References folly::EventBaseManager::clearEventBase(), folly::IOThreadPoolExecutor::IOThread::eventBase, eventBaseManager_, folly::EventBaseManager::getEventBase(), folly::gen::guard(), folly::ThreadPoolExecutor::isJoin_, folly::ThreadPoolExecutor::isWaitForAll_, folly::ThreadPoolListHook::registerThread(), thisThread_, and folly::ThreadPoolExecutor::threadPoolHook_.
|
private |
Definition at line 94 of file IOThreadPoolExecutor.h.
Referenced by getEventBaseManager(), and threadRun().
|
private |
Definition at line 92 of file IOThreadPoolExecutor.h.
Referenced by pickThread().
|
private |
Definition at line 93 of file IOThreadPoolExecutor.h.
Referenced by pickThread(), and threadRun().