Navigation Menu

Skip to content

Commit

Permalink
Get some more mileage out of push-worker()
Browse files Browse the repository at this point in the history
- should improve readability
  • Loading branch information
lizmat committed Oct 27, 2017
1 parent 6ac53e4 commit 2cd568f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/core/ThreadPoolScheduler.pm
Expand Up @@ -339,15 +339,13 @@ my class ThreadPoolScheduler does Scheduler {
unless $!timer-queue.DEFINITE {
# We don't have any workers yet, so start one.
$!timer-queue := nqp::create(Queue);
my $workers := nqp::create(IterationBuffer);
nqp::push(
$workers,
$!timer-workers := push-worker(
nqp::create(IterationBuffer),
TimerWorker.new(
queue => $!timer-queue,
scheduler => self
)
);
$!timer-workers := $workers;
scheduler-debug "Created initial timer worker thread";
self!maybe-start-supervisor();
}
Expand All @@ -365,14 +363,12 @@ my class ThreadPoolScheduler does Scheduler {
if $!affinity-workers.elems == 0 {
# We don't have any affinity workers yet, so start one
# and return its queue.
my $workers := nqp::create(IterationBuffer);
nqp::push(
$workers,
$!affinity-workers := push-worker(
nqp::create(IterationBuffer),
AffinityWorker.new(
scheduler => self
)
);
$!affinity-workers := $workers;
scheduler-debug "Created initial affinity worker thread";
self!maybe-start-supervisor();
return $!affinity-workers[0].queue;
Expand Down

0 comments on commit 2cd568f

Please sign in to comment.