pub struct V8TaskSpawner { /* private fields */ }
Expand description

Allows for submission of v8 tasks on the same thread.

Implementations§

source§

impl V8TaskSpawner

source

pub fn spawn<F>(&self, f: F)
where F: FnOnce(&mut HandleScope<'_>) + 'static,

Spawn a task that runs within the crate::JsRuntime event loop from the same thread that the runtime is running on. This function is re-entrant-safe and may be called from ops, from outside of a v8::HandleScope in a plain `async`` task, or even from within another, previously-spawned task.

The task is handed off to be run the next time the event loop is polled, and there are no guarantees as to when this may happen.

Safety

The task shares the same v8::HandleScope as the core event loop, which means that it must maintain the scope in a valid state to avoid corrupting or destroying the runtime.

For example, if the code called by this task can raise an exception, the task must ensure that it calls that code within a new v8::TryCatch to avoid the exception leaking to the event loop’s v8::HandleScope.

Trait Implementations§

source§

impl Clone for V8TaskSpawner

source§

fn clone(&self) -> V8TaskSpawner

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.