Commit edbdc3d4 authored by James Sedgwick's avatar James Sedgwick Committed by Andrii Grynenko

in thread pools, take factory as shared ptr

Summary: needed for thrift server. if you have some sort of stateful/functional factory and you want to hold on to it, you should be allowed to

Test Plan: compiles with forthcoming thrift diff

Reviewed By: davejwatson@fb.com

Subscribers: trunkagent, fugalh, njormrod

FB internal diff: D1584587
parent ca5fc366
......@@ -23,7 +23,7 @@ const size_t CPUThreadPoolExecutor::kDefaultMaxQueueSize = 1 << 18;
CPUThreadPoolExecutor::CPUThreadPoolExecutor(
size_t numThreads,
std::unique_ptr<BlockingQueue<CPUTask>> taskQueue,
std::unique_ptr<ThreadFactory> threadFactory)
std::shared_ptr<ThreadFactory> threadFactory)
: ThreadPoolExecutor(numThreads, std::move(threadFactory)),
taskQueue_(std::move(taskQueue)) {
addThreads(numThreads);
......
......@@ -28,8 +28,8 @@ class CPUThreadPoolExecutor : public ThreadPoolExecutor {
std::unique_ptr<BlockingQueue<CPUTask>> taskQueue =
folly::make_unique<LifoSemMPMCQueue<CPUTask>>(
CPUThreadPoolExecutor::kDefaultMaxQueueSize),
std::unique_ptr<ThreadFactory> threadFactory =
folly::make_unique<NamedThreadFactory>("CPUThreadPool"));
std::shared_ptr<ThreadFactory> threadFactory =
std::make_shared<NamedThreadFactory>("CPUThreadPool"));
~CPUThreadPoolExecutor();
......
......@@ -24,7 +24,7 @@ namespace folly { namespace wangle {
IOThreadPoolExecutor::IOThreadPoolExecutor(
size_t numThreads,
std::unique_ptr<ThreadFactory> threadFactory)
std::shared_ptr<ThreadFactory> threadFactory)
: ThreadPoolExecutor(numThreads, std::move(threadFactory)),
nextThread_(0) {
addThreads(numThreads);
......
......@@ -24,8 +24,8 @@ class IOThreadPoolExecutor : public ThreadPoolExecutor {
public:
explicit IOThreadPoolExecutor(
size_t numThreads,
std::unique_ptr<ThreadFactory> threadFactory =
folly::make_unique<NamedThreadFactory>("IOThreadPool"));
std::shared_ptr<ThreadFactory> threadFactory =
std::make_shared<NamedThreadFactory>("IOThreadPool"));
~IOThreadPoolExecutor();
......
......@@ -20,7 +20,7 @@ namespace folly { namespace wangle {
ThreadPoolExecutor::ThreadPoolExecutor(
size_t numThreads,
std::unique_ptr<ThreadFactory> threadFactory)
std::shared_ptr<ThreadFactory> threadFactory)
: threadFactory_(std::move(threadFactory)) {}
ThreadPoolExecutor::~ThreadPoolExecutor() {
......
......@@ -35,7 +35,7 @@ class ThreadPoolExecutor : public experimental::Executor {
public:
explicit ThreadPoolExecutor(
size_t numThreads,
std::unique_ptr<ThreadFactory> threadFactory);
std::shared_ptr<ThreadFactory> threadFactory);
~ThreadPoolExecutor();
......@@ -157,7 +157,7 @@ class ThreadPoolExecutor : public experimental::Executor {
std::queue<ThreadPtr> queue_;
};
std::unique_ptr<ThreadFactory> threadFactory_;
std::shared_ptr<ThreadFactory> threadFactory_;
ThreadList threadList_;
RWSpinLock threadListLock_;
StoppedThreadQueue stoppedThreads_;
......
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