/*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2017-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
namespace folly {
-TestExecutor::TestExecutor() {
- const auto kWorkers = std::max(1U, thread::hardware_concurrency());
- for (auto idx = 0U; idx < kWorkers; ++idx) {
+TestExecutor::TestExecutor(size_t numThreads) {
+ const auto kWorkers = std::max(size_t(1), numThreads);
+ for (auto idx = 0u; idx < kWorkers; ++idx) {
workers_.emplace_back([this] {
while (true) {
Func work;
TestExecutor::~TestExecutor() {
for (auto& worker : workers_) {
+ (void)worker;
addImpl({});
}
}
}
-uint32_t TestExecutor::numThreads() const {
+size_t TestExecutor::numThreads() const {
return workers_.size();
}
cv_.notify_one();
}
-} // folly
+} // namespace folly