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
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);
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();
IOThreadPoolExecutor::IOThreadPoolExecutor(
size_t numThreads,
- std::unique_ptr<ThreadFactory> threadFactory)
+ std::shared_ptr<ThreadFactory> threadFactory)
: ThreadPoolExecutor(numThreads, std::move(threadFactory)),
nextThread_(0) {
addThreads(numThreads);
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();
ThreadPoolExecutor::ThreadPoolExecutor(
size_t numThreads,
- std::unique_ptr<ThreadFactory> threadFactory)
+ std::shared_ptr<ThreadFactory> threadFactory)
: threadFactory_(std::move(threadFactory)) {}
ThreadPoolExecutor::~ThreadPoolExecutor() {
public:
explicit ThreadPoolExecutor(
size_t numThreads,
- std::unique_ptr<ThreadFactory> threadFactory);
+ std::shared_ptr<ThreadFactory> threadFactory);
~ThreadPoolExecutor();
std::queue<ThreadPtr> queue_;
};
- std::unique_ptr<ThreadFactory> threadFactory_;
+ std::shared_ptr<ThreadFactory> threadFactory_;
ThreadList threadList_;
RWSpinLock threadListLock_;
StoppedThreadQueue stoppedThreads_;