Commit bc1365d3 authored by Constantin Dolghier's avatar Constantin Dolghier Committed by Facebook GitHub Bot

Move isWaitForAll_ from ThreadPoolExecutor to IOThreadPoolExecutor

Summary:
I randomly ran into this while working on something else: ThreadPoolExecutor has a field `isWaitForAll_` which:
* is only used in its subclass, `IOThreadPoolExecutor`
* has a comment referencing evbs, which ThreadPoolExecutor doesn't have relationship to but the subclass does.

Looks like this is an artefact of some old refactoring

Reviewed By: yfeldblum

Differential Revision: D31117228

fbshipit-source-id: ea7d1753a0d75ab8911cec68f3b6fb8c1f07c569
parent 5c748c42
...@@ -86,8 +86,8 @@ IOThreadPoolExecutor::IOThreadPoolExecutor( ...@@ -86,8 +86,8 @@ IOThreadPoolExecutor::IOThreadPoolExecutor(
: ThreadPoolExecutor( : ThreadPoolExecutor(
numThreads, numThreads,
FLAGS_dynamic_iothreadpoolexecutor ? 0 : numThreads, FLAGS_dynamic_iothreadpoolexecutor ? 0 : numThreads,
std::move(threadFactory), std::move(threadFactory)),
waitForAll), isWaitForAll_(waitForAll),
nextThread_(0), nextThread_(0),
eventBaseManager_(ebm) { eventBaseManager_(ebm) {
setNumThreads(numThreads); setNumThreads(numThreads);
...@@ -100,8 +100,8 @@ IOThreadPoolExecutor::IOThreadPoolExecutor( ...@@ -100,8 +100,8 @@ IOThreadPoolExecutor::IOThreadPoolExecutor(
std::shared_ptr<ThreadFactory> threadFactory, std::shared_ptr<ThreadFactory> threadFactory,
EventBaseManager* ebm, EventBaseManager* ebm,
bool waitForAll) bool waitForAll)
: ThreadPoolExecutor( : ThreadPoolExecutor(maxThreads, minThreads, std::move(threadFactory)),
maxThreads, minThreads, std::move(threadFactory), waitForAll), isWaitForAll_(waitForAll),
nextThread_(0), nextThread_(0),
eventBaseManager_(ebm) { eventBaseManager_(ebm) {
setNumThreads(maxThreads); setNumThreads(maxThreads);
......
...@@ -102,6 +102,7 @@ class IOThreadPoolExecutor : public ThreadPoolExecutor, public IOExecutor { ...@@ -102,6 +102,7 @@ class IOThreadPoolExecutor : public ThreadPoolExecutor, public IOExecutor {
void stopThreads(size_t n) override; void stopThreads(size_t n) override;
size_t getPendingTaskCountImpl() const override final; size_t getPendingTaskCountImpl() const override final;
const bool isWaitForAll_; // whether to wait till event base loop exits
std::atomic<size_t> nextThread_; std::atomic<size_t> nextThread_;
folly::ThreadLocal<std::shared_ptr<IOThread>> thisThread_; folly::ThreadLocal<std::shared_ptr<IOThread>> thisThread_;
folly::EventBaseManager* eventBaseManager_; folly::EventBaseManager* eventBaseManager_;
......
...@@ -48,10 +48,8 @@ DEFINE_int64( ...@@ -48,10 +48,8 @@ DEFINE_int64(
ThreadPoolExecutor::ThreadPoolExecutor( ThreadPoolExecutor::ThreadPoolExecutor(
size_t /* maxThreads */, size_t /* maxThreads */,
size_t minThreads, size_t minThreads,
std::shared_ptr<ThreadFactory> threadFactory, std::shared_ptr<ThreadFactory> threadFactory)
bool isWaitForAll)
: threadFactory_(std::move(threadFactory)), : threadFactory_(std::move(threadFactory)),
isWaitForAll_(isWaitForAll),
taskStatsCallbacks_(std::make_shared<TaskStatsCallbackRegistry>()), taskStatsCallbacks_(std::make_shared<TaskStatsCallbackRegistry>()),
threadPoolHook_("folly::ThreadPoolExecutor"), threadPoolHook_("folly::ThreadPoolExecutor"),
minThreads_(minThreads), minThreads_(minThreads),
......
...@@ -69,8 +69,7 @@ class ThreadPoolExecutor : public DefaultKeepAliveExecutor { ...@@ -69,8 +69,7 @@ class ThreadPoolExecutor : public DefaultKeepAliveExecutor {
explicit ThreadPoolExecutor( explicit ThreadPoolExecutor(
size_t maxThreads, size_t maxThreads,
size_t minThreads, size_t minThreads,
std::shared_ptr<ThreadFactory> threadFactory, std::shared_ptr<ThreadFactory> threadFactory);
bool isWaitForAll = false);
~ThreadPoolExecutor() override; ~ThreadPoolExecutor() override;
...@@ -287,7 +286,6 @@ class ThreadPoolExecutor : public DefaultKeepAliveExecutor { ...@@ -287,7 +286,6 @@ class ThreadPoolExecutor : public DefaultKeepAliveExecutor {
std::shared_ptr<ThreadFactory> threadFactory_; std::shared_ptr<ThreadFactory> threadFactory_;
std::string namePrefix_; std::string namePrefix_;
const bool isWaitForAll_; // whether to wait till event base loop exits
ThreadList threadList_; ThreadList threadList_;
SharedMutex threadListLock_; SharedMutex threadListLock_;
......
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