Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update docs on Scheduler.cue edge case handling
  • Loading branch information
Kaiepi committed May 6, 2019
1 parent f64f1b9 commit b0bd2bb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
9 changes: 5 additions & 4 deletions doc/Type/Scheduler.pod6
Expand Up @@ -51,10 +51,11 @@ C<$times> tells the scheduler how many times to run the code.
C<&catch> is called with the L<Exception|/type/Exception> as its sole argument
if C<&code> dies.
If C<$at>, C<$in>, or C<$every> are C<Inf>, C<&code> will never be run. If any
of them are C<-Inf>, C<&code> will be run immediately. If any of them are
C<NaN>, an C<X::AdHoc> exception will be thrown with the message "Cannot set
NaN as a number of seconds".
If C<$at> or C<$in> are C<Inf>, C<&code> will never be run; if C<$every> is
C<Inf>, C<&code> will only be run once. If any of the three are C<-Inf>,
C<&code> will be run immediately. If any of the three are C<NaN>, an
L<X::Scheduler::CueInNaNSeconds|/type/X/Scheduler/CueInNanSeconds> exception
will be thrown. This only applies to versions 2019.04 and later.
One should call the C<cancel> method on the returned C<Cancellation> object
to cancel the (possibly repeated) cueing of the code.
Expand Down
23 changes: 23 additions & 0 deletions doc/Type/X/Scheduler/CueInNaNSeconds.pod6
@@ -0,0 +1,23 @@
=begin pod
=TITLE class X::Scheduler::CueInNaNSeconds
=SUBTITLE Error caused by passing NaN to Scheduler.cue as :at, :in, or :every
class X::Scheduler::CueInNaNSeconds is Exception { }
In versions 2019.04 and later, when calling C<ThreadPoolScheduler.cue> or
C<CurrentThreadScheduler.cue> with C<:at>, C<:in>, or C<:every> as C<NaN>, this
exception gets thrown. For example, the following code:
=for code :skip-test
my Cancellation $c = $*SCHEDULER.cue({
say 'This will never output :(';
}, at => NaN);
Throws with:
=for code :lang<text>
Cannot pass NaN as a number of seconds
=end pod

0 comments on commit b0bd2bb

Please sign in to comment.