Skip to content

Commit

Permalink
Let CPUThreadPoolExecutor use unbounded queues
Browse files Browse the repository at this point in the history
Summary:
[Folly] Let CPUThreadPoolExecutor use unbounded queues when no queue bounds are specified.

One constructor remains which specifies queue bounds; that constructor uses bounded queues.

Reviewed By: andriigrynenko

Differential Revision: D15113118

fbshipit-source-id: 9c8ace4f170fdfdeef152e55b371d434ad248866
  • Loading branch information
yfeldblum authored and facebook-github-bot committed May 10, 2019
1 parent 82a5342 commit 9a096e5
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions folly/executors/CPUThreadPoolExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <folly/executors/CPUThreadPoolExecutor.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>

DEFINE_bool(
Expand Down Expand Up @@ -57,17 +59,15 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor(
std::shared_ptr<ThreadFactory> threadFactory)
: CPUThreadPoolExecutor(
numThreads,
std::make_unique<LifoSemMPMCQueue<CPUTask>>(
CPUThreadPoolExecutor::kDefaultMaxQueueSize),
std::make_unique<UnboundedBlockingQueue<CPUTask>>(),
std::move(threadFactory)) {}

CPUThreadPoolExecutor::CPUThreadPoolExecutor(
std::pair<size_t, size_t> numThreads,
std::shared_ptr<ThreadFactory> threadFactory)
: CPUThreadPoolExecutor(
numThreads,
std::make_unique<LifoSemMPMCQueue<CPUTask>>(
CPUThreadPoolExecutor::kDefaultMaxQueueSize),
std::make_unique<UnboundedBlockingQueue<CPUTask>>(),
std::move(threadFactory)) {}

CPUThreadPoolExecutor::CPUThreadPoolExecutor(size_t numThreads)
Expand All @@ -81,9 +81,8 @@ CPUThreadPoolExecutor::CPUThreadPoolExecutor(
std::shared_ptr<ThreadFactory> threadFactory)
: CPUThreadPoolExecutor(
numThreads,
std::make_unique<PriorityLifoSemMPMCQueue<CPUTask>>(
numPriorities,
CPUThreadPoolExecutor::kDefaultMaxQueueSize),
std::make_unique<PriorityUnboundedBlockingQueue<CPUTask>>(
numPriorities),
std::move(threadFactory)) {}

CPUThreadPoolExecutor::CPUThreadPoolExecutor(
Expand Down

0 comments on commit 9a096e5

Please sign in to comment.