Commit d8c01bbb authored by Dominik Charousset's avatar Dominik Charousset

Fix work stealing when using only one worker

parent 71b20538
...@@ -94,6 +94,10 @@ class work_stealing { ...@@ -94,6 +94,10 @@ class work_stealing {
template <class Worker> template <class Worker>
resumable* try_steal(Worker* self) { resumable* try_steal(Worker* self) {
auto p = self->parent(); auto p = self->parent();
if (p->num_workers() < 2) {
// you can't steal from yourself, can you?
return nullptr;
}
size_t victim; size_t victim;
do { do {
// roll the dice to pick a victim other than ourselves // roll the dice to pick a victim other than ourselves
...@@ -199,12 +203,10 @@ class work_stealing { ...@@ -199,12 +203,10 @@ class work_stealing {
template <class Worker> template <class Worker>
void after_resume(Worker* self) { void after_resume(Worker* self) {
// give others the opportunity to steal from us // give others the opportunity to steal from us
/*
if (d(self).private_queue.size() > 1 && d(self).exposed_queue.empty()) { if (d(self).private_queue.size() > 1 && d(self).exposed_queue.empty()) {
d(self).exposed_queue.push_back(d(self).private_queue.front()); d(self).exposed_queue.push_back(d(self).private_queue.front());
d(self).private_queue.pop_front(); d(self).private_queue.pop_front();
} }
*/
} }
template <class Worker, class UnaryFunction> template <class Worker, class UnaryFunction>
......
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