Struct brane_exe::thread::Thread

source ·
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>

source

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.

source

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.
source

pub fn fork(&self, offset: ProgramCounter) -> Self

‘Forks’ this thread such that it may branch in a parallel statement.

§Arguments
  • offset: The offset (as a (body, idx) pair) where the thread will begin computation in the edges list.
§Returns

A new Thread that is partly cloned of this one.

source

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.

source

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T