role Scheduler

Scheme for automatically assigning tasks to threads

role Scheduler {
    has &.uncaught_handler is rw
}

A scheduler is a piece of code that determines which resources to use to run which task, and when. This role contains code that will be the same for all kinds of schedulers.

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 --> Cancellation)

Schedules a callable (&code) for execution and returns an instantiated Cancellation object to cancel the scheduling of the code for execution (which is especially important if you specify the :every ( time ) named parameter). The adverbs control when and how the code is run:

One should call the cancel method on the returned Cancellation object to cancel the (possibly repeated) cueing of the code.

method loads

Defined as:

method loads()

This is a method stub, should be re-implemented when subclassing.

Type Graph

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

Expand above chart