Commit 0d2f150b authored by Akrama Baig Mirza's avatar Akrama Baig Mirza Committed by Facebook GitHub Bot

Use Options struct in IOThreadPoolExecutor constructor

Summary: Avoid using `bool` directly in `IOThreadPoolExecutor` constructor

Reviewed By: yfeldblum, praihan

Differential Revision: D33769477

fbshipit-source-id: ba16d676d2130c7680c960cd27f43174f06d0475
parent 9ad0307f
...@@ -82,12 +82,12 @@ IOThreadPoolExecutor::IOThreadPoolExecutor( ...@@ -82,12 +82,12 @@ IOThreadPoolExecutor::IOThreadPoolExecutor(
size_t numThreads, size_t numThreads,
std::shared_ptr<ThreadFactory> threadFactory, std::shared_ptr<ThreadFactory> threadFactory,
EventBaseManager* ebm, EventBaseManager* ebm,
bool waitForAll) Options options)
: ThreadPoolExecutor( : ThreadPoolExecutor(
numThreads, numThreads,
FLAGS_dynamic_iothreadpoolexecutor ? 0 : numThreads, FLAGS_dynamic_iothreadpoolexecutor ? 0 : numThreads,
std::move(threadFactory)), std::move(threadFactory)),
isWaitForAll_(waitForAll), isWaitForAll_(options.waitForAll),
nextThread_(0), nextThread_(0),
eventBaseManager_(ebm) { eventBaseManager_(ebm) {
setNumThreads(numThreads); setNumThreads(numThreads);
...@@ -99,9 +99,9 @@ IOThreadPoolExecutor::IOThreadPoolExecutor( ...@@ -99,9 +99,9 @@ IOThreadPoolExecutor::IOThreadPoolExecutor(
size_t minThreads, size_t minThreads,
std::shared_ptr<ThreadFactory> threadFactory, std::shared_ptr<ThreadFactory> threadFactory,
EventBaseManager* ebm, EventBaseManager* ebm,
bool waitForAll) Options options)
: ThreadPoolExecutor(maxThreads, minThreads, std::move(threadFactory)), : ThreadPoolExecutor(maxThreads, minThreads, std::move(threadFactory)),
isWaitForAll_(waitForAll), isWaitForAll_(options.waitForAll),
nextThread_(0), nextThread_(0),
eventBaseManager_(ebm) { eventBaseManager_(ebm) {
setNumThreads(maxThreads); setNumThreads(maxThreads);
......
...@@ -56,12 +56,23 @@ FOLLY_MSVC_DISABLE_WARNING(4250) ...@@ -56,12 +56,23 @@ FOLLY_MSVC_DISABLE_WARNING(4250)
*/ */
class IOThreadPoolExecutor : public ThreadPoolExecutor, public IOExecutor { class IOThreadPoolExecutor : public ThreadPoolExecutor, public IOExecutor {
public: public:
struct Options {
Options() : waitForAll(false) {}
Options& setWaitForAll(bool b) {
this->waitForAll = b;
return *this;
}
bool waitForAll;
};
explicit IOThreadPoolExecutor( explicit IOThreadPoolExecutor(
size_t numThreads, size_t numThreads,
std::shared_ptr<ThreadFactory> threadFactory = std::shared_ptr<ThreadFactory> threadFactory =
std::make_shared<NamedThreadFactory>("IOThreadPool"), std::make_shared<NamedThreadFactory>("IOThreadPool"),
folly::EventBaseManager* ebm = folly::EventBaseManager::get(), folly::EventBaseManager* ebm = folly::EventBaseManager::get(),
bool waitForAll = false); Options options = Options());
IOThreadPoolExecutor( IOThreadPoolExecutor(
size_t maxThreads, size_t maxThreads,
...@@ -69,7 +80,7 @@ class IOThreadPoolExecutor : public ThreadPoolExecutor, public IOExecutor { ...@@ -69,7 +80,7 @@ class IOThreadPoolExecutor : public ThreadPoolExecutor, public IOExecutor {
std::shared_ptr<ThreadFactory> threadFactory = std::shared_ptr<ThreadFactory> threadFactory =
std::make_shared<NamedThreadFactory>("IOThreadPool"), std::make_shared<NamedThreadFactory>("IOThreadPool"),
folly::EventBaseManager* ebm = folly::EventBaseManager::get(), folly::EventBaseManager* ebm = folly::EventBaseManager::get(),
bool waitForAll = false); Options options = Options());
~IOThreadPoolExecutor() override; ~IOThreadPoolExecutor() override;
......
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