#include <folly/Executor.h>
#include <folly/executors/CPUThreadPoolExecutor.h>
#include <atomic>
#include <folly/Memory.h>
#include <folly/Optional.h>
#include <folly/executors/QueueObserver.h>
#include <folly/executors/task_queue/PriorityLifoSemMPMCQueue.h>
#include <folly/executors/task_queue/PriorityUnboundedBlockingQueue.h>
#include <folly/executors/task_queue/UnboundedBlockingQueue.h>
#include <folly/portability/GFlags.h>
#include <folly/synchronization/ThrottledLifoSem.h>
FOLLY_GFLAGS_DEFINE_bool(…);
namespace folly {
const size_t CPUThreadPoolExecutor::kDefaultMaxQueueSize = …;
CPUThreadPoolExecutor::CPUTask::CPUTask(
Func&& f,
std::chrono::milliseconds expiration,
Func&& expireCallback,
int8_t pri)
: … { … }
CPUThreadPoolExecutor::CPUTask::CPUTask()
: … { … }
auto CPUThreadPoolExecutor::makeDefaultQueue()
-> std::unique_ptr<BlockingQueue<CPUTask>> { … }
auto CPUThreadPoolExecutor::makeDefaultPriorityQueue(
int8_t numPriorities) -> std::unique_ptr<BlockingQueue<CPUTask>> { … }
auto CPUThreadPoolExecutor::makeThrottledLifoSemQueue(
std::chrono::nanoseconds wakeUpInterval)
-> std::unique_ptr<BlockingQueue<CPUTask>> { … }
auto CPUThreadPoolExecutor::makeThrottledLifoSemPriorityQueue(
int8_t numPriorities, std::chrono::nanoseconds wakeUpInterval)
-> std::unique_ptr<BlockingQueue<CPUTask>> { … }
CPUThreadPoolExecutor::CPUThreadPoolExecutor(
size_t numThreads,
std::unique_ptr<BlockingQueue<CPUTask>> taskQueue,
std::shared_ptr<ThreadFactory> threadFactory,
Options opt)
: … { … }
CPUThreadPoolExecutor::CPUThreadPoolExecutor(
std::pair<size_t, size_t> numThreads,
std::unique_ptr<BlockingQueue<CPUTask>> taskQueue,
std::shared_ptr<ThreadFactory> threadFactory,
Options opt)
: … { … }
CPUThreadPoolExecutor::CPUThreadPoolExecutor(
size_t numThreads,
std::shared_ptr<ThreadFactory> threadFactory,
Options opt)
: … { … }
CPUThreadPoolExecutor::CPUThreadPoolExecutor(
std::pair<size_t, size_t> numThreads,
std::shared_ptr<ThreadFactory> threadFactory,
Options opt)
: … { … }
CPUThreadPoolExecutor::CPUThreadPoolExecutor(size_t numThreads, Options opt)
: … { … }
CPUThreadPoolExecutor::CPUThreadPoolExecutor(
size_t numThreads,
int8_t numPriorities,
std::shared_ptr<ThreadFactory> threadFactory,
Options opt)
: … { … }
CPUThreadPoolExecutor::CPUThreadPoolExecutor(
size_t numThreads,
int8_t numPriorities,
size_t maxQueueSize,
std::shared_ptr<ThreadFactory> threadFactory,
Options opt)
: … { … }
CPUThreadPoolExecutor::~CPUThreadPoolExecutor() { … }
QueueObserver* FOLLY_NULLABLE
CPUThreadPoolExecutor::getQueueObserver(int8_t pri) { … }
void CPUThreadPoolExecutor::add(Func func) { … }
void CPUThreadPoolExecutor::add(
Func func, std::chrono::milliseconds expiration, Func expireCallback) { … }
void CPUThreadPoolExecutor::addWithPriority(Func func, int8_t priority) { … }
void CPUThreadPoolExecutor::add(
Func func,
int8_t priority,
std::chrono::milliseconds expiration,
Func expireCallback) { … }
template <bool withPriority>
void CPUThreadPoolExecutor::addImpl(
Func func,
int8_t priority,
std::chrono::milliseconds expiration,
Func expireCallback) { … }
uint8_t CPUThreadPoolExecutor::getNumPriorities() const { … }
size_t CPUThreadPoolExecutor::getTaskQueueSize() const { … }
WorkerProvider* CPUThreadPoolExecutor::getThreadIdCollector() { … }
BlockingQueue<CPUThreadPoolExecutor::CPUTask>*
CPUThreadPoolExecutor::getTaskQueue() { … }
bool CPUThreadPoolExecutor::tryDecrToStop() { … }
bool CPUThreadPoolExecutor::taskShouldStop(folly::Optional<CPUTask>& task) { … }
void CPUThreadPoolExecutor::threadRun(ThreadPtr thread) { … }
void CPUThreadPoolExecutor::stopThreads(size_t n) { … }
size_t CPUThreadPoolExecutor::getPendingTaskCountImpl() const { … }
std::unique_ptr<folly::QueueObserverFactory>
CPUThreadPoolExecutor::createQueueObserverFactory() { … }
}