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