Summary:
Seems useful to do without passing in a totally custom queue. Makes
the client code a bit simpler.
Test Plan: used it, saw low memory usage and no crash
Reviewed By: davejwatson@fb.com
Subscribers: trunkagent, iaroslav, fugalh, folly-diffs@, jsedgwick, yfeldblum, slarsen
FB internal diff:
D1907874
Signature: t1:
1907874:
1426268010:
3159ae339b51f5dbc7fe034644bbc968b92b072c
CPUThreadPoolExecutor::kDefaultMaxQueueSize),
std::move(threadFactory)) {}
+CPUThreadPoolExecutor::CPUThreadPoolExecutor(
+ size_t numThreads,
+ uint32_t numPriorities,
+ size_t maxQueueSize,
+ std::shared_ptr<ThreadFactory> threadFactory)
+ : CPUThreadPoolExecutor(
+ numThreads,
+ folly::make_unique<PriorityLifoSemMPMCQueue<CPUTask>>(
+ numPriorities,
+ maxQueueSize),
+ std::move(threadFactory)) {}
+
CPUThreadPoolExecutor::~CPUThreadPoolExecutor() {
stop();
CHECK(threadsToStop_ == 0);
std::shared_ptr<ThreadFactory> threadFactory =
std::make_shared<NamedThreadFactory>("CPUThreadPool"));
+ explicit CPUThreadPoolExecutor(
+ size_t numThreads,
+ uint32_t numPriorities,
+ size_t maxQueueSize,
+ std::shared_ptr<ThreadFactory> threadFactory =
+ std::make_shared<NamedThreadFactory>("CPUThreadPool"));
+
~CPUThreadPoolExecutor();
void add(Func func) override;