Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Ensure there's a thread for timer events.
Also, a minor simplification.
  • Loading branch information
jnthn committed Apr 19, 2014
1 parent 3814ab3 commit f7dcaa7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/ThreadPoolScheduler.pm
Expand Up @@ -67,21 +67,23 @@ my class ThreadPoolScheduler does Scheduler {
nqp::timer($!queue,
&catch
?? -> { code(); CATCH { default { catch($_) } } }
!! -> { code() },
!! &code,
($delay * 1000).Int, ($every * 1000).Int,
AsyncCancellation);
self!maybe_new_thread() if !$!started_any
}

# only after waiting a bit or more than once
elsif $delay or $times > 1 {
my $todo := &catch
?? -> { code(); CATCH { default { catch($_) } } }
!! -> { code() };
!! &code;
for 1 .. $times {
nqp::timer($!queue, $todo, ($delay * 1000).Int, 0,
AsyncCancellation);
$delay = 0;
}
self!maybe_new_thread() if !$!started_any
}

# just cue the code
Expand Down

0 comments on commit f7dcaa7

Please sign in to comment.