Skip to main content

JobExecutor

Trait JobExecutor 

Source
pub trait JobExecutor: Any {
    // Required methods
    fn enqueue_job(self: Rc<Self>, job: Job, context: &mut Context);
    fn run_jobs(self: Rc<Self>, context: &mut Context) -> JsResult<()>;

    // Provided method
    async fn run_jobs_async(
        self: Rc<Self>,
        context: &RefCell<&mut Context>,
    ) -> JsResult<()>
       where Self: Sized { ... }
}
Expand description

An executor of ECMAscript Jobs.

This is the main API that allows creating custom event loops.

Required Methods§

Source

fn enqueue_job(self: Rc<Self>, job: Job, context: &mut Context)

Enqueues a Job on the executor.

This method combines all the host-defined job enqueueing operations into a single method. See the spec for more information on the requirements that each operation must follow.

Source

fn run_jobs(self: Rc<Self>, context: &mut Context) -> JsResult<()>

Runs all jobs in the executor.

Provided Methods§

Source

async fn run_jobs_async( self: Rc<Self>, context: &RefCell<&mut Context>, ) -> JsResult<()>
where Self: Sized,

Asynchronously runs all jobs in the executor.

By default forwards to JobExecutor::run_jobs. Implementors using async should override this with a proper algorithm to run jobs asynchronously.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§