Commit 651e1e2e authored by Dominik Charousset's avatar Dominik Charousset

Merge pull request #392 from Lingxi-Li/topic/victim_selection_dev

Improve `policy::work_stealing::try_steal()`
parents 9b71fc86 5a90717a
...@@ -91,12 +91,10 @@ public: ...@@ -91,12 +91,10 @@ public:
// you can't steal from yourself, can you? // you can't steal from yourself, can you?
return nullptr; return nullptr;
} }
size_t victim;
do {
// roll the dice to pick a victim other than ourselves // roll the dice to pick a victim other than ourselves
victim = d(self).rengine() % p->num_workers(); size_t victim = d(self).rengine() % (p->num_workers() - 1);
} if (victim == self->id())
while (victim == self->id()); victim = p->num_workers() - 1;
// steal oldest element from the victim's queue // steal oldest element from the victim's queue
return d(p->worker_by_id(victim)).queue.take_tail(); return d(p->worker_by_id(victim)).queue.take_tail();
} }
......
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