allow setting the thread count for coroutine scheduler

master
Daniel Kolesa 2017-03-26 14:38:39 +02:00
parent cdf3875b81
commit b86b7f9b29
1 changed files with 6 additions and 3 deletions

View File

@ -474,8 +474,10 @@ private:
};
public:
basic_coroutine_scheduler(SA &&sa = SA{}):
p_stacks(std::move(sa))
basic_coroutine_scheduler(
size_t thrs = std::thread::hardware_concurrency(), SA &&sa = SA{}
):
p_threads(thrs), p_stacks(std::move(sa))
{}
~basic_coroutine_scheduler() {}
@ -593,7 +595,7 @@ private:
}
void init() {
size_t size = std::thread::hardware_concurrency();
size_t size = p_threads;
std::vector<std::thread> thrs;
thrs.reserve(size);
for (size_t i = 0; i < size; ++i) {
@ -682,6 +684,7 @@ private:
}
}
size_t p_threads;
std::condition_variable p_cond;
std::mutex p_lock;
SA p_stacks;