pub struct Thread<G: CustomGlobalState, L: CustomLocalState> { /* private fields */ }
Expand description
Represents a single thread that may be executed.
Implementations§
source§impl<G: CustomGlobalState, L: CustomLocalState> Thread<G, L>
impl<G: CustomGlobalState, L: CustomLocalState> Thread<G, L>
sourcepub fn new(workflow: &Workflow, global: G) -> Self
pub fn new(workflow: &Workflow, global: G) -> Self
Spawns a new main thread from the given workflow.
§Arguments
workflow
: The Workflow that this thread will execute.pindex
: The PackageIndex we use to resolve packages.dindex
: The DataIndex we use to resolve datasets.global
: The app-wide custom state with which to initialize this thread.
§Returns
A new Thread that may be executed.
sourcepub fn from_state(workflow: &Workflow, state: RunState<G>) -> Self
pub fn from_state(workflow: &Workflow, state: RunState<G>) -> Self
Spawns a new main thread that does not start from scratch but instead the given VmState.
§Arguments
workflow
: The workflow to execute.state
: The runstate to “resume” this thread with.
sourcepub fn fork(&self, offset: ProgramCounter) -> Self
pub fn fork(&self, offset: ProgramCounter) -> Self
sourcepub fn run<P: VmPlugin<GlobalState = G, LocalState = L>>(
self,
prof: ProfileScopeHandleOwned,
) -> BoxFuture<'static, Result<Value, Error>>
pub fn run<P: VmPlugin<GlobalState = G, LocalState = L>>( self, prof: ProfileScopeHandleOwned, ) -> BoxFuture<'static, Result<Value, Error>>
Runs the thread once until it is pending for something (either other threads or external function calls).
§Arguments
-
prof
: A ProfileScopeHandleOwned that is used to provide more details about the execution times of a workflow execution. Note that this is not user-relevant, only debug/framework-relevant.The reason it is owned is due to the boxed return future. It’s your responsibility to keep the parent into scope after the future returns; if you don’t any collected profile results will likely not be printed.
§Returns
The value that this thread returns once it is done.
§Errors
This function may error if execution of an edge or instruction failed. This is typically due to incorrect runtime typing.
sourcepub fn run_snippet<P: VmPlugin<GlobalState = G, LocalState = L>>(
self,
prof: ProfileScopeHandleOwned,
) -> BoxFuture<'static, Result<(Value, RunState<G>), Error>>
pub fn run_snippet<P: VmPlugin<GlobalState = G, LocalState = L>>( self, prof: ProfileScopeHandleOwned, ) -> BoxFuture<'static, Result<(Value, RunState<G>), Error>>
Runs the thread once until it is pending for something (either other threads or external function calls).
This overload supports snippet execution, returning the state that is necessary for the next repl-loop together with the result.
§Arguments
-
prof
: A ProfileScopeHandleOwned that is used to provide more details about the execution times of a workflow execution. Note that this is not user-relevant, only debug/framework-relevant.The reason it is owned is due to the boxed return future. It’s your responsibility to keep the parent into scope after the future returns; if you don’t any collected profile results will likely not be printed.
§Returns
A tuple of the value that is returned by this thread and the running state used to refer to variables produced in this run, respectively.
§Errors
This function may error if execution of an edge or instruction failed. This is typically due to incorrect runtime typing.
Auto Trait Implementations§
impl<G, L> Freeze for Thread<G, L>where
L: Freeze,
impl<G, L> RefUnwindSafe for Thread<G, L>where
L: RefUnwindSafe,
impl<G, L> Send for Thread<G, L>
impl<G, L> Sync for Thread<G, L>
impl<G, L> Unpin for Thread<G, L>where
L: Unpin,
impl<G, L> UnwindSafe for Thread<G, L>where
L: UnwindSafe,
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> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request