role Scheduler

Scheme for automatically assigning tasks to threads

role Scheduler {
    has &.uncaught_handler is rw
}

Common role for schedulers. A scheduler is a piece of code that determines which resources to use to run which task, and when.

Some operations for example on Proc::Async, Promise, Supply allow you to specify a scheduler explicitly; they generally expect those schedulers to follow the interface defined by Scheduler

Methods

method uncaught_handler

method uncaught_handler() is rw

RW-Accessor for the handler that is caught for uncaught exceptions from the code that is being scheduled and run.

method cue

method cue(:&codeInstant :$at:$in:$every:$times = 1:&catch)

Schedules a callable (&code) for execution. The adverbs control when and how the code is run:

$at can be an Instant before which the code won't be run. Alternatively $in is the number of seconds (possibly fractional) to wait before running the code.

If $every is specified, it is interpreted as the number of seconds (possibly fractional) to wait before re-executing the code.

$times tells the scheduler how many times to run the code.

&catch is called with the Exception as its sole argument if &code dies.

Type graph

Type relations for Scheduler
perl6-type-graph Scheduler Scheduler Mu Mu Any Any Any->Mu CurrentThreadScheduler CurrentThreadScheduler CurrentThreadScheduler->Scheduler CurrentThreadScheduler->Any ThreadPoolScheduler ThreadPoolScheduler ThreadPoolScheduler->Scheduler ThreadPoolScheduler->Any

Stand-alone image: vector