From edbdc3d4f05788eb41eb9719bfeb113e0a1ea52d Mon Sep 17 00:00:00 2001 From: James Sedgwick Date: Wed, 1 Oct 2014 10:55:34 -0700 Subject: [PATCH] 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 --- .../experimental/wangle/concurrent/CPUThreadPoolExecutor.cpp | 2 +- folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.h | 4 ++-- folly/experimental/wangle/concurrent/IOThreadPoolExecutor.cpp | 2 +- folly/experimental/wangle/concurrent/IOThreadPoolExecutor.h | 4 ++-- folly/experimental/wangle/concurrent/ThreadPoolExecutor.cpp | 2 +- folly/experimental/wangle/concurrent/ThreadPoolExecutor.h | 4 ++-- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.cpp b/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.cpp index 6d826b55..715bd372 100644 --- a/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.cpp +++ b/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.cpp @@ -23,7 +23,7 @@ const size_t CPUThreadPoolExecutor::kDefaultMaxQueueSize = 1 << 18; CPUThreadPoolExecutor::CPUThreadPoolExecutor( size_t numThreads, std::unique_ptr> taskQueue, - std::unique_ptr threadFactory) + std::shared_ptr threadFactory) : ThreadPoolExecutor(numThreads, std::move(threadFactory)), taskQueue_(std::move(taskQueue)) { addThreads(numThreads); diff --git a/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.h b/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.h index 28e2dad6..f331232f 100644 --- a/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.h +++ b/folly/experimental/wangle/concurrent/CPUThreadPoolExecutor.h @@ -28,8 +28,8 @@ class CPUThreadPoolExecutor : public ThreadPoolExecutor { std::unique_ptr> taskQueue = folly::make_unique>( CPUThreadPoolExecutor::kDefaultMaxQueueSize), - std::unique_ptr threadFactory = - folly::make_unique("CPUThreadPool")); + std::shared_ptr threadFactory = + std::make_shared("CPUThreadPool")); ~CPUThreadPoolExecutor(); diff --git a/folly/experimental/wangle/concurrent/IOThreadPoolExecutor.cpp b/folly/experimental/wangle/concurrent/IOThreadPoolExecutor.cpp index 8de3d5ab..a58b3f44 100644 --- a/folly/experimental/wangle/concurrent/IOThreadPoolExecutor.cpp +++ b/folly/experimental/wangle/concurrent/IOThreadPoolExecutor.cpp @@ -24,7 +24,7 @@ namespace folly { namespace wangle { IOThreadPoolExecutor::IOThreadPoolExecutor( size_t numThreads, - std::unique_ptr threadFactory) + std::shared_ptr threadFactory) : ThreadPoolExecutor(numThreads, std::move(threadFactory)), nextThread_(0) { addThreads(numThreads); diff --git a/folly/experimental/wangle/concurrent/IOThreadPoolExecutor.h b/folly/experimental/wangle/concurrent/IOThreadPoolExecutor.h index a6bf5215..7acaafe8 100644 --- a/folly/experimental/wangle/concurrent/IOThreadPoolExecutor.h +++ b/folly/experimental/wangle/concurrent/IOThreadPoolExecutor.h @@ -24,8 +24,8 @@ class IOThreadPoolExecutor : public ThreadPoolExecutor { public: explicit IOThreadPoolExecutor( size_t numThreads, - std::unique_ptr threadFactory = - folly::make_unique("IOThreadPool")); + std::shared_ptr threadFactory = + std::make_shared("IOThreadPool")); ~IOThreadPoolExecutor(); diff --git a/folly/experimental/wangle/concurrent/ThreadPoolExecutor.cpp b/folly/experimental/wangle/concurrent/ThreadPoolExecutor.cpp index d8ddfac1..5924f736 100644 --- a/folly/experimental/wangle/concurrent/ThreadPoolExecutor.cpp +++ b/folly/experimental/wangle/concurrent/ThreadPoolExecutor.cpp @@ -20,7 +20,7 @@ namespace folly { namespace wangle { ThreadPoolExecutor::ThreadPoolExecutor( size_t numThreads, - std::unique_ptr threadFactory) + std::shared_ptr threadFactory) : threadFactory_(std::move(threadFactory)) {} ThreadPoolExecutor::~ThreadPoolExecutor() { diff --git a/folly/experimental/wangle/concurrent/ThreadPoolExecutor.h b/folly/experimental/wangle/concurrent/ThreadPoolExecutor.h index 54819ad6..7cbbb321 100644 --- a/folly/experimental/wangle/concurrent/ThreadPoolExecutor.h +++ b/folly/experimental/wangle/concurrent/ThreadPoolExecutor.h @@ -35,7 +35,7 @@ class ThreadPoolExecutor : public experimental::Executor { public: explicit ThreadPoolExecutor( size_t numThreads, - std::unique_ptr threadFactory); + std::shared_ptr threadFactory); ~ThreadPoolExecutor(); @@ -157,7 +157,7 @@ class ThreadPoolExecutor : public experimental::Executor { std::queue queue_; }; - std::unique_ptr threadFactory_; + std::shared_ptr threadFactory_; ThreadList threadList_; RWSpinLock threadListLock_; StoppedThreadQueue stoppedThreads_; -- 2.34.1