Commit aae7c5b3 authored by Matt Dordal's avatar Matt Dordal Committed by Andre Azevedo

Add ctor to CPUThreadPoolExecutor to enable custom queue sizes

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
parent 383ffb34
......@@ -57,6 +57,18 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor(
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);
......
......@@ -42,6 +42,13 @@ class CPUThreadPoolExecutor : public ThreadPoolExecutor {
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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment