Struct muse_reactor::BudgetPoolHandle
source · pub struct BudgetPoolHandle<Work = NoWork>(/* private fields */);Expand description
A handle to a budget pool.
Tasks spawned in a budget pool will only be able to execute while the budget pool has remaining budget.
When all handles to a budget pool have been dropped, all outstanding tasks belonging to the budget pool will be cancelled.
Implementations§
source§impl<Work> BudgetPoolHandle<Work>where
Work: WorkUnit,
impl<Work> BudgetPoolHandle<Work>where
Work: WorkUnit,
sourcepub fn id(&self) -> BudgetPoolId
pub fn id(&self) -> BudgetPoolId
Returns the id of this pool.
sourcepub fn spawn(&self, vm: Vm) -> Result<TaskHandle, ReactorShutdown>
pub fn spawn(&self, vm: Vm) -> Result<TaskHandle, ReactorShutdown>
Spawns vm in the reactor, returning a handle to the spawned task.
Builder::new_vm can be used to customize what functionality is
available in every virtual machine.
This task will execute with a shared budget and will be paused when no budget is available in this pool.
sourcepub fn spawn_source(
&self,
source: impl Into<String>,
) -> Result<TaskHandle, ReactorShutdown>
pub fn spawn_source( &self, source: impl Into<String>, ) -> Result<TaskHandle, ReactorShutdown>
Spawns a task that compiles and executes source.
Builder::new_vm can be used to customize how source is compiled
and what functionality is available in every virtual machine.
This task will execute with a shared budget and will be paused when no budget is available in this pool.
sourcepub fn spawn_call(
&self,
code: Code,
args: Vec<RootedValue>,
) -> Result<TaskHandle, ReactorShutdown>
pub fn spawn_call( &self, code: Code, args: Vec<RootedValue>, ) -> Result<TaskHandle, ReactorShutdown>
Spawns a task that executes code after loading args to the virtual
machine registers.
Builder::new_vm can be used to customize what functionality is
available in every virtual machine.
This task will execute with a shared budget and will be paused when no budget is available in this pool.
sourcepub fn spawn_work(&self, work: Work) -> Result<TaskHandle, ReactorShutdown>
pub fn spawn_work(&self, work: Work) -> Result<TaskHandle, ReactorShutdown>
Spawns a task that executes work.
This function allows a user-specified type to be spawned and converted
into a task using the WorkUnit trait.
Builder::new_vm can be used to customize the Work generic and what
functionality is available in every virtual machine.
This task will execute with a shared budget and will be paused when no budget is available in this pool.
sourcepub fn increase_budget(&self, amount: usize)
pub fn increase_budget(&self, amount: usize)
Adds amount to the budget.
This function cannot increase the budget above
BudgetPoolConfig::maximum.
sourcepub fn remaining_budget(&self) -> usize
pub fn remaining_budget(&self) -> usize
Returns the currently remaining budget.
sourcepub fn reactor(&self) -> &ReactorHandle<Work>
pub fn reactor(&self) -> &ReactorHandle<Work>
Returns a handle to the reactor this pool belongs to.
Trait Implementations§
source§impl<Work> Clone for BudgetPoolHandle<Work>
impl<Work> Clone for BudgetPoolHandle<Work>
source§impl<Work> Debug for BudgetPoolHandle<Work>
impl<Work> Debug for BudgetPoolHandle<Work>
impl<Work> ContainsNoRefs for BudgetPoolHandle<Work>where
Work: WorkUnit,
Auto Trait Implementations§
impl<Work> Freeze for BudgetPoolHandle<Work>
impl<Work = NoWork> !RefUnwindSafe for BudgetPoolHandle<Work>
impl<Work> Send for BudgetPoolHandle<Work>where
Work: Send,
impl<Work> Sync for BudgetPoolHandle<Work>where
Work: Send,
impl<Work> Unpin for BudgetPoolHandle<Work>
impl<Work = NoWork> !UnwindSafe for BudgetPoolHandle<Work>
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
§impl<A> Cast for A
impl<A> Cast for A
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit)