forked from OctaForge/libostd
allow setting the thread count for coroutine scheduler
This commit is contained in:
parent
cdf3875b81
commit
b86b7f9b29
|
@ -474,8 +474,10 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
basic_coroutine_scheduler(SA &&sa = SA{}):
|
basic_coroutine_scheduler(
|
||||||
p_stacks(std::move(sa))
|
size_t thrs = std::thread::hardware_concurrency(), SA &&sa = SA{}
|
||||||
|
):
|
||||||
|
p_threads(thrs), p_stacks(std::move(sa))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
~basic_coroutine_scheduler() {}
|
~basic_coroutine_scheduler() {}
|
||||||
|
@ -593,7 +595,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
size_t size = std::thread::hardware_concurrency();
|
size_t size = p_threads;
|
||||||
std::vector<std::thread> thrs;
|
std::vector<std::thread> thrs;
|
||||||
thrs.reserve(size);
|
thrs.reserve(size);
|
||||||
for (size_t i = 0; i < size; ++i) {
|
for (size_t i = 0; i < size; ++i) {
|
||||||
|
@ -682,6 +684,7 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t p_threads;
|
||||||
std::condition_variable p_cond;
|
std::condition_variable p_cond;
|
||||||
std::mutex p_lock;
|
std::mutex p_lock;
|
||||||
SA p_stacks;
|
SA p_stacks;
|
||||||
|
|
Loading…
Reference in a new issue