Struct rquickjs_core::runtime::AsyncRuntime
source · pub struct AsyncRuntime { /* private fields */ }
Expand description
Asynchronous QuickJS runtime, entry point of the library.
Implementations§
source§impl AsyncRuntime
impl AsyncRuntime
sourcepub fn new() -> Result<Self>
pub fn new() -> Result<Self>
Create a new runtime.
Will generally only fail if not enough memory was available.
§Features
If the "rust-alloc"
feature is enabled the Rust’s global allocator will be used in favor of libc’s one.
sourcepub fn new_with_alloc<A>(allocator: A) -> Result<Self>where
A: Allocator + 'static,
Available on crate feature allocator
only.
pub fn new_with_alloc<A>(allocator: A) -> Result<Self>where
A: Allocator + 'static,
allocator
only.Create a new runtime using specified allocator
Will generally only fail if not enough memory was available.
sourcepub fn weak(&self) -> AsyncWeakRuntime
pub fn weak(&self) -> AsyncWeakRuntime
Get weak ref to runtime
sourcepub async fn set_interrupt_handler(&self, handler: Option<InterruptHandler>)
pub async fn set_interrupt_handler(&self, handler: Option<InterruptHandler>)
Set a closure which is regularly called by the engine when it is executing code.
If the provided closure returns true
the interpreter will raise and uncatchable
exception and return control flow to the caller.
sourcepub async fn set_loader<R, L>(&self, resolver: R, loader: L)
Available on crate feature loader
only.
pub async fn set_loader<R, L>(&self, resolver: R, loader: L)
loader
only.Set the module loader
sourcepub async fn set_info<S: Into<Vec<u8>>>(&self, info: S) -> Result<()>
pub async fn set_info<S: Into<Vec<u8>>>(&self, info: S) -> Result<()>
Set the info of the runtime
sourcepub async fn set_memory_limit(&self, limit: usize)
pub async fn set_memory_limit(&self, limit: usize)
Set a limit on the max amount of memory the runtime will use.
Setting the limit to 0 is equivalent to unlimited memory.
Note that is a Noop when a custom allocator is being used, as is the case for the “rust-alloc” or “allocator” features.
sourcepub async fn set_max_stack_size(&self, limit: usize)
pub async fn set_max_stack_size(&self, limit: usize)
Set a limit on the max size of stack the runtime will use.
The default values is 256x1024 bytes.
sourcepub async fn set_gc_threshold(&self, threshold: usize)
pub async fn set_gc_threshold(&self, threshold: usize)
Set a memory threshold for garbage collection.
sourcepub async fn run_gc(&self)
pub async fn run_gc(&self)
Manually run the garbage collection.
Most QuickJS values are reference counted and will automatically free themselves when they have no more references. The garbage collector is only for collecting cyclic references.
sourcepub async fn memory_usage(&self) -> MemoryUsage
pub async fn memory_usage(&self) -> MemoryUsage
Get memory usage stats
sourcepub async fn is_job_pending(&self) -> bool
pub async fn is_job_pending(&self) -> bool
Test for pending jobs
Returns true when at least one job is pending.
sourcepub async fn execute_pending_job(&self) -> StdResult<bool, AsyncJobException>
pub async fn execute_pending_job(&self) -> StdResult<bool, AsyncJobException>
Execute first pending job
Returns true when job was executed or false when queue is empty or error when exception thrown under execution.
Trait Implementations§
source§impl Clone for AsyncRuntime
impl Clone for AsyncRuntime
source§fn clone(&self) -> AsyncRuntime
fn clone(&self) -> AsyncRuntime
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for AsyncRuntime
impl !RefUnwindSafe for AsyncRuntime
impl !Send for AsyncRuntime
impl !Sync for AsyncRuntime
impl Unpin for AsyncRuntime
impl !UnwindSafe for AsyncRuntime
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more