Skip to main content

Module job

Module job 

Source
Expand description

Boa’s API to create and customize ECMAScript jobs and job queues.

Job is an ECMAScript Job, or a closure that runs an ECMAScript computation when there’s no other computation running. The module defines several type of jobs:

JobCallback is an ECMAScript JobCallback record, containing an ECMAScript function that is executed when a promise is either fulfilled or rejected.

JobExecutor is a trait encompassing the required functionality for a job executor; this allows implementing custom event loops, custom handling of Jobs or other fun things. This trait is also accompanied by two implementors of the trait:

  • IdleJobExecutor, which is an executor that does nothing, and the default executor if no executor is provided. Useful for hosts that want to disable promises.
  • SimpleJobExecutor, which is a simple FIFO queue that runs all jobs to completion, bailing on the first error encountered. This simple executor will block on any async job queued.

§Trace?

Most of the types defined in this module don’t implement Trace. This is because most jobs can only be run once, and putting a JobExecutor on a garbage collected object is not allowed.

In addition to that, not implementing Trace makes it so that the garbage collector can consider any captured variables inside jobs as roots, since you cannot store jobs within a Gc.

Structs§

CancellationToken
Token to cancel a TimeoutJob and IntervalJob.
GenericJob
An ECMAScript Generic Job.
IdleJobExecutor
A job executor that does nothing.
IntervalJob
An ECMAScript Job that runs at a certain interval of time.
JobCallback
JobCallback records.
NativeAsyncJob
An ECMAScript Job that can be run asynchronously.
NativeJob
An ECMAScript Job Abstract Closure.
NativeJobFn
An ECMAScript Job Abstract Closure that can be called multiple times.
PromiseJob
An ECMAScript Job Abstract Closure executing code related to Promise objects.
SimpleJobExecutor
A simple FIFO executor that bails on the first error.
TimeoutJob
An ECMAScript Job that runs after a certain amount of time.

Enums§

Job
A job that needs to be handled by a JobExecutor.

Traits§

JobExecutor
An executor of ECMAscript Jobs.

Type Aliases§

BoxedFuture
The Future job returned by a NativeAsyncJob operation.