Struct deno_core::V8TaskSpawner
source · pub struct V8TaskSpawner { /* private fields */ }
Expand description
Allows for submission of v8 tasks on the same thread.
Implementations§
source§impl V8TaskSpawner
impl V8TaskSpawner
sourcepub fn spawn<F>(&self, f: F)where
F: FnOnce(&mut HandleScope<'_>) + 'static,
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
impl Clone for V8TaskSpawner
source§fn clone(&self) -> V8TaskSpawner
fn clone(&self) -> V8TaskSpawner
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more