[][src]Struct rusty_v8::Isolate

#[repr(C)]
pub struct Isolate(_);

Isolate represents an isolated instance of the V8 engine. V8 isolates have completely separate states. Objects from one isolate must not be used in other isolates. The embedder can create multiple isolates and use them in parallel in multiple threads. An isolate can be entered by at most one thread at any given time. The Locker/Unlocker API must be used to synchronize.

Methods

impl Isolate[src]

pub fn new(params: UniqueRef<CreateParams>) -> OwnedIsolate[src]

Creates a new isolate. Does not change the currently entered isolate.

When an isolate is no longer used its resources should be freed by calling V8::dispose(). Using the delete operator is not allowed.

V8::initialize() must have run prior to this.

pub fn create_params() -> UniqueRef<CreateParams>[src]

Initial configuration parameters for a new Isolate.

pub unsafe fn set_data(&mut self, slot: u32, ptr: *mut c_void)[src]

Associate embedder-specific data with the isolate. |slot| has to be between 0 and GetNumberOfDataSlots() - 1.

pub fn get_data(&self, slot: u32) -> *mut c_void[src]

Retrieve embedder-specific data from the isolate. Returns NULL if SetData has never been called for the given |slot|.

pub fn get_number_of_data_slots(&self) -> u32[src]

Returns the maximum number of available embedder data slots. Valid slots are in the range of 0 - GetNumberOfDataSlots() - 1.

pub fn enter(&mut self)[src]

Sets this isolate as the entered one for the current thread. Saves the previously entered one (if any), so that it can be restored when exiting. Re-entering an isolate is allowed.

pub fn exit(&mut self)[src]

Exits this isolate by restoring the previously entered one in the current thread. The isolate may still stay the same, if it was entered more than once.

Requires: self == Isolate::GetCurrent().

pub fn get_current_context<'sc>(&mut self) -> Local<'sc, Context>[src]

Returns the context of the currently running JavaScript, or the context on the top of the stack if no JavaScript is running.

pub fn set_capture_stack_trace_for_uncaught_exceptions(
    &mut self,
    capture: bool,
    frame_limit: i32
)
[src]

Tells V8 to capture current stack trace when uncaught exception occurs and report it to the message listeners. The option is off by default.

pub fn add_message_listener(&mut self, callback: MessageCallback) -> bool[src]

Adds a message listener (errors only).

The same message listener can be added more than once and in that case it will be called more than once for each message.

The exception object will be passed to the callback.

pub fn set_promise_reject_callback(&mut self, callback: PromiseRejectCallback)[src]

Set callback to notify about promise reject with no handler, or revocation of such a previous notification once the handler is added.

pub fn set_host_initialize_import_meta_object_callback(
    &mut self,
    callback: HostInitializeImportMetaObjectCallback
)
[src]

This specifies the callback called by the upcoming importa.meta language feature to retrieve host-defined meta data for a module.

pub fn set_host_import_module_dynamically_callback(
    &mut self,
    callback: HostImportModuleDynamicallyCallback
)
[src]

This specifies the callback called by the upcoming dynamic import() language feature to load modules.

pub fn throw_exception<'sc>(&self, exception: Local<Value>) -> Local<'sc, Value>[src]

Schedules an exception to be thrown when returning to JavaScript. When an exception has been scheduled it is illegal to invoke any JavaScript operation; the caller must return immediately and only after the exception has been handled does it become legal to invoke JavaScript operations.

pub fn terminate_execution(&self)[src]

Forcefully terminate the current thread of JavaScript execution in the given isolate.

This method can be used by any thread even if that thread has not acquired the V8 lock with a Locker object.

pub fn is_execution_terminating(&self) -> bool[src]

Is V8 terminating JavaScript execution.

Returns true if JavaScript execution is currently terminating because of a call to TerminateExecution. In that case there are still JavaScript frames on the stack and the termination exception is still active.

pub fn cancel_terminate_execution(&self)[src]

Resume execution capability in the given isolate, whose execution was previously forcefully terminated using TerminateExecution().

When execution is forcefully terminated using TerminateExecution(), the isolate can not resume execution until all JavaScript frames have propagated the uncatchable exception which is generated. This method allows the program embedding the engine to handle the termination event and resume execution capability, even if JavaScript frames remain on the stack.

This method can be used by any thread even if that thread has not acquired the V8 lock with a Locker object.

pub fn run_microtasks(&self)[src]

Runs the default MicrotaskQueue until it gets empty. Any exceptions thrown by microtask callbacks are swallowed.

pub fn enqueue_microtask(&self, microtask: Local<Function>)[src]

Enqueues the callback to the default MicrotaskQueue

pub fn request_interrupt(
    &self,
    callback: extern "C" fn(isolate: &mut Isolate, data: *mut c_void),
    data: *mut c_void
)
[src]

Request V8 to interrupt long running JavaScript code and invoke the given |callback| passing the given |data| to it. After |callback| returns control will be returned to the JavaScript code. There may be a number of interrupt requests in flight. Can be called from another thread without acquiring a |Locker|. Registered |callback| must not reenter interrupted Isolate.

pub unsafe fn dispose(&mut self)[src]

Disposes the isolate. The isolate must not be entered by any thread to be disposable.

Trait Implementations

impl<'s> From<&'s mut Isolate> for Scope<'s, CallbackScope>[src]

Auto Trait Implementations

impl RefUnwindSafe for Isolate

impl Send for Isolate

impl Sync for Isolate

impl Unpin for Isolate

impl UnwindSafe for Isolate

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.