Skip to content
Permalink
Browse files

Handle edge cases with :at/:in in CurrentThreadScheduler.cue

  • Loading branch information...
Kaiepi committed May 6, 2019
1 parent de76a05 commit c977d6c57aa40cb54e42b4a668a8ef7f463ab6a6
Showing with 17 additions and 1 deletion.
  1. +17 −1 src/core/CurrentThreadScheduler.pm6
@@ -14,7 +14,23 @@ my class CurrentThreadScheduler does Scheduler {
die "Cannot specify :every in {self.^name}"
if $every;

my $delay = $at ?? $at - now !! $in;
my $delay := nqp::decont($at ?? $at - now !! $in);
nqp::if(
nqp::istype($delay, Num),
nqp::if(
nqp::iseq_n($delay, nqp::inf()),
(return class { method cancel() {} }),
nqp::if(
nqp::iseq_n($delay, nqp::neginf()),
($delay := 0),
nqp::if(
nqp::isnanorinf($delay),
(die "Cannot set NaN as a number of seconds")
)
)
)
);

sleep $delay if $delay;
&catch //=
(self && self.uncaught_handler) // -> $ex { self.handle_uncaught($ex) };

0 comments on commit c977d6c

Please sign in to comment.
You can’t perform that action at this time.