Skip to content
Permalink
Browse files

Allow :at/:in/:every to be Inf/-Inf/NaN in ThreadPoolScheduler.cue

Before, this would throw with a somewhat cryptic error.
Now, this uses the smallest time interval allowed for the parameter.
  • Loading branch information...
Kaiepi committed Mar 9, 2019
1 parent 70d61b2 commit cc88d63db3eb810d15e1ab921c85a91e221a6fda
Showing with 19 additions and 8 deletions.
  1. +19 −8 src/core/ThreadPoolScheduler.pm6
@@ -840,20 +840,31 @@ my class ThreadPoolScheduler does Scheduler {
}

sub to-millis(Numeric() $value) {
nqp::if(
nqp::isgt_i((my int $proposed = (1000 * $value).Int),0),
$proposed,
nqp::unless(
nqp::isnanorinf($value.Num),
nqp::if(
nqp::isgt_i((my int $proposed = (1000 * $value).Int),0),
$proposed,
nqp::stmts(
warn("Minimum timer resolution is 1ms; using that instead of {1000 * $value}ms"),
1
)
),
nqp::stmts(
warn("Minimum timer resolution is 1ms; using that instead of {1000 * $value}ms"),
warn("Minimum timer resolution is 1ms; using that instead of {$value}ms"),
1
)
)
}
sub to-millis-allow-zero(Numeric() $value) {
nqp::if(
nqp::isgt_i((my int $proposed = (1000 * $value).Int),0),
$proposed
# not true == 0 == what we need
nqp::unless(
nqp::isnanorinf($value.Num),
nqp::if(
nqp::isgt_i((my int $proposed = (1000 * $value).Int), 0),
$proposed,
# not true == 0 == what we need
),
0
)
}
sub wrap-catch(&code, &catch) {

0 comments on commit cc88d63

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