Skip to content

Commit

Permalink
Remove Worker.worked, it was too heavy to be run always
Browse files Browse the repository at this point in the history
Also move update of Worker.total to run-one
- so we don't lose any completions not seen by supervisor yet at end
  • Loading branch information
lizmat committed Nov 1, 2017
1 parent b386963 commit 2377624
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/core/ThreadPoolScheduler.pm
Expand Up @@ -202,9 +202,6 @@ my class ThreadPoolScheduler does Scheduler {
# Total number of tasks completed since creation.
has int $.total;

# Wallclock seconds actually worked
has num $.worked;

# Working is 1 if the worker is currently busy, 0 if not.
has int $.working;

Expand All @@ -225,26 +222,20 @@ my class ThreadPoolScheduler does Scheduler {
++$!times-nothing-completed;
}
else {
$!total = $!total + $taken;
$!times-nothing-completed = 0;
}
$taken
}

method !run-one(\task --> Nil) {
my num $start;
$!working = 1;
nqp::continuationreset(THREAD_POOL_PROMPT, {
if nqp::istype(task, List) {
my Mu $code := nqp::shift(nqp::getattr(task, List, '$!reified'));
$start = nqp::time_n;
$code(|task);
$!worked = nqp::add_n($!worked,nqp::sub_n(nqp::time_n,$start));
}
else {
$start = nqp::time_n;
task.();
$!worked = nqp::add_n($!worked,nqp::sub_n(nqp::time_n,$start));
}
CONTROL {
default {
Expand All @@ -265,6 +256,7 @@ my class ThreadPoolScheduler does Scheduler {
#?if !moar
++$!completed;
#?endif
++$!total;
}
}
my class GeneralWorker does Worker {
Expand Down

0 comments on commit 2377624

Please sign in to comment.