pub struct Runtime {
cx: *mut JSContext,
engine: JSEngineHandle,
_parent_child_count: Option<Arc<()>>,
outstanding_children: Arc<()>,
}
Expand description
A wrapper for the JSContext
structure in SpiderMonkey.
Fields§
§cx: *mut JSContext
Raw pointer to the underlying SpiderMonkey context.
engine: JSEngineHandle
The engine that this runtime is associated with.
_parent_child_count: Option<Arc<()>>
If this Runtime was created with a parent, this member exists to ensure that that parent’s count of outstanding children (see [outstanding_children]) remains accurate and will be automatically decreased when this Runtime value is dropped.
outstanding_children: Arc<()>
The strong references to this value represent the number of child runtimes
that have been created using this Runtime as a parent. Since Runtime values
must be associated with a particular thread, we cannot simply use Arc
Implementations§
source§impl Runtime
impl Runtime
sourcepub fn new(engine: JSEngineHandle) -> Runtime
pub fn new(engine: JSEngineHandle) -> Runtime
Creates a new JSContext
.
sourcepub fn prepare_for_new_child(&self) -> ParentRuntime
pub fn prepare_for_new_child(&self) -> ParentRuntime
Signal that a new child runtime will be created in the future, and ensure
that this runtime will not allow itself to be destroyed before the new
child runtime. Returns a handle that can be passed to create_with_parent
in order to create a new runtime on another thread that is associated with
this runtime.
sourcepub unsafe fn create_with_parent(parent: ParentRuntime) -> Runtime
pub unsafe fn create_with_parent(parent: ParentRuntime) -> Runtime
Creates a new JSContext
with a parent runtime. If the parent does not outlive
the new runtime, its destructor will assert.
Unsafety: If panicking does not abort the program, any threads with child runtimes will continue executing after the thread with the parent runtime panics, but they will be in an invalid and undefined state.