Struct rquickjs_core::Runtime
source · [−]#[repr(transparent)]pub struct Runtime { /* private fields */ }
Expand description
Quickjs runtime, entry point of the library.
Implementations
sourceimpl Runtime
impl Runtime
sourcepub fn idle(&self) -> IdleⓘNotable traits for Idleimpl Future for Idle type Output = ();
Available on crate feature futures
only.
pub fn idle(&self) -> IdleⓘNotable traits for Idleimpl Future for Idle type Output = ();
futures
only.Await until all pending jobs and spawned futures will be done
sourcepub fn run_executor(&self) -> ExecutorⓘNotable traits for Executorimpl Future for Executor type Output = ();
Available on crate feature futures
only.
pub fn run_executor(&self) -> ExecutorⓘNotable traits for Executorimpl Future for Executor type Output = ();
futures
only.Run pending jobs and futures executor
sourcepub fn spawn_executor<A: ExecutorSpawner>(&self, spawner: A) -> A::JoinHandle
Available on crate feature futures
only.
pub fn spawn_executor<A: ExecutorSpawner>(&self, spawner: A) -> A::JoinHandle
futures
only.Spawn pending jobs and futures executor
sourcepub fn spawn<F, T>(&self, future: F) where
F: Future<Output = T> + ParallelSend + 'static,
T: ParallelSend + 'static,
Available on crate feature futures
only.
pub fn spawn<F, T>(&self, future: F) where
F: Future<Output = T> + ParallelSend + 'static,
T: ParallelSend + 'static,
futures
only.Spawn future using runtime
sourceimpl Runtime
impl Runtime
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 set_interrupt_handler(
&self,
handler: Option<Box<dyn FnMut() -> bool + 'static>>
)
pub fn set_interrupt_handler(
&self,
handler: Option<Box<dyn FnMut() -> bool + 'static>>
)
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 fn set_loader<R, L>(&self, resolver: R, loader: L) where
R: Resolver + 'static,
L: Loader + 'static,
Available on crate feature loader
only.
pub fn set_loader<R, L>(&self, resolver: R, loader: L) where
R: Resolver + 'static,
L: Loader + 'static,
loader
only.Set the module loader
sourcepub fn set_memory_limit(&self, limit: usize)
pub 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 fn set_max_stack_size(&self, limit: usize)
pub 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 fn set_gc_threshold(&self, threshold: usize)
pub fn set_gc_threshold(&self, threshold: usize)
Set a memory threshold for garbage collection.
sourcepub fn run_gc(&self)
pub fn run_gc(&self)
Manually run the garbage collection.
Most of quickjs values are reference counted and will automaticly free themselfs when they have no more references. The garbage collector is only for collecting cyclic references.
sourcepub fn memory_usage(&self) -> MemoryUsage
pub fn memory_usage(&self) -> MemoryUsage
Get memory usage stats
sourcepub fn is_job_pending(&self) -> bool
pub fn is_job_pending(&self) -> bool
Test for pending jobs
Returns true when at least one job is pending.
sourcepub fn execute_pending_job(&self) -> Result<bool>
pub fn execute_pending_job(&self) -> Result<bool>
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
Auto Trait Implementations
impl !RefUnwindSafe for Runtime
impl !Send for Runtime
impl !Sync for Runtime
impl Unpin for Runtime
impl !UnwindSafe for Runtime
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more