Skip to content

Commit

Permalink
Only take really idle affinity workers straight away in ThreadPoolSch…
Browse files Browse the repository at this point in the history
…eduler

Looking at the queue length alone doesn't tell us whether a worker is idle or
not. We also have to take it's working flag into account. Otherwise we may end
up picking a busy worker straight away when there's an actually idle one
standing by.
  • Loading branch information
niner committed Apr 19, 2020
1 parent 77a2201 commit 750abe0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core.c/ThreadPoolScheduler.pm6
Expand Up @@ -433,7 +433,10 @@ my class ThreadPoolScheduler does Scheduler {
(my $cand := nqp::atpos($cur-affinity-workers,$i)),
nqp::unless(
nqp::elems(my $queue := $cand.queue),
(return $queue)
nqp::unless(
$cand.working,
(return $queue),
),
),
nqp::if(
nqp::islt_i(
Expand Down

0 comments on commit 750abe0

Please sign in to comment.