pub struct VmScopeFuture<'a, SE>where
SE: ScriptExpression,{
pub scope: VmScope<'a, SE>,
pub context: VmScopeFutureContext,
pub registry: Arc<Registry>,
pub operations_per_poll: usize,
}Expand description
A VmScope driven by an executor instead of by a loop.
Each poll steps the scope up to operations_per_poll times. It reports
Poll::Ready once the scope is done, and
Poll::Pending when the scope suspends, when
the poll budget runs out, or when the context cannot be borrowed right now.
The future never wakes itself, so the executor has to poll it again on its own.
Fields§
§scope: VmScope<'a, SE>The scope being stepped.
context: VmScopeFutureContextThe context the scope runs on.
registry: Arc<Registry>The registry the scope looks types and functions up in.
operations_per_poll: usizeHow many operations one poll runs at most.
Implementations§
Source§impl<'a, SE> VmScopeFuture<'a, SE>where
SE: ScriptExpression,
impl<'a, SE> VmScopeFuture<'a, SE>where
SE: ScriptExpression,
Sourcepub fn new(
scope: VmScope<'a, SE>,
context: impl Into<VmScopeFutureContext>,
registry: Arc<Registry>,
) -> VmScopeFuture<'a, SE> ⓘ
pub fn new( scope: VmScope<'a, SE>, context: impl Into<VmScopeFutureContext>, registry: Arc<Registry>, ) -> VmScopeFuture<'a, SE> ⓘ
Wraps scope into a future, with no limit on operations per poll.
Sourcepub fn operations_per_poll(self, value: usize) -> VmScopeFuture<'a, SE> ⓘ
pub fn operations_per_poll(self, value: usize) -> VmScopeFuture<'a, SE> ⓘ
Sets how many operations one poll runs at most, builder style.
A small number hands control back to the executor more often, so one long script cannot hold up everything else.