Skip to main content

ParallelWorkflow

Struct ParallelWorkflow 

Source
pub struct ParallelWorkflow<A, B, SA: BranchState, SB: BranchState> {
    pub branch_a: BranchToken<A, SA>,
    pub branch_b: BranchToken<B, SB>,
}
Expand description

Tracks the status of two concurrent branches (A and B) at compile time.

§Representation

Struct ParallelWorkflow containing branch_a and branch_b of type BranchToken<A, SA> and BranchToken<B, SB> respectively. Since both tokens are zero-sized, ParallelWorkflow is also zero-sized (0 bytes).

§Structure-only

Models an AND-split/concurrency pattern between two branches without using OS threads, async futures, or mutexes.

§Graduation

Graduates to wasm4pm’s parallel gateways (BPMN AND-split and AND-join, or Petri Net transitions) which manage dynamic, multi-threaded or distributed scheduling.

Fields§

§branch_a: BranchToken<A, SA>§branch_b: BranchToken<B, SB>

Implementations§

Source§

impl<A, B> ParallelWorkflow<A, B, Pending, Pending>

Source

pub fn split() -> Self

Initializes a parallel workflow split (AND-Split).

§Examples
use wasm4pm_compat::workflow::{ParallelWorkflow, Pending};

struct TaskA;
struct TaskB;
let workflow: ParallelWorkflow<TaskA, TaskB, Pending, Pending> = ParallelWorkflow::split();
Source§

impl<A, B, SB: BranchState> ParallelWorkflow<A, B, Running, SB>

Source

pub fn complete_a(self) -> ParallelWorkflow<A, B, Completed, SB>

Completes the task on Branch A.

§Examples
use wasm4pm_compat::workflow::{ParallelWorkflow, Pending, Running, Completed};

struct TaskA;
struct TaskB;
let workflow: ParallelWorkflow<TaskA, TaskB, Pending, Pending> = ParallelWorkflow::split();
// Start both branches
let workflow = ParallelWorkflow {
    branch_a: workflow.branch_a.start(),
    branch_b: workflow.branch_b.start(),
};
// Complete branch A
let workflow: ParallelWorkflow<TaskA, TaskB, Completed, Running> = workflow.complete_a();
Source§

impl<A, B, SA: BranchState> ParallelWorkflow<A, B, SA, Running>

Source

pub fn complete_b(self) -> ParallelWorkflow<A, B, SA, Completed>

Completes the task on Branch B.

§Examples
use wasm4pm_compat::workflow::{ParallelWorkflow, Pending, Running, Completed};

struct TaskA;
struct TaskB;
let workflow: ParallelWorkflow<TaskA, TaskB, Pending, Pending> = ParallelWorkflow::split();
// Start both branches
let workflow = ParallelWorkflow {
    branch_a: workflow.branch_a.start(),
    branch_b: workflow.branch_b.start(),
};
// Complete branch B
let workflow: ParallelWorkflow<TaskA, TaskB, Running, Completed> = workflow.complete_b();
Source§

impl<A, B> ParallelWorkflow<A, B, Running, Running>

Source

pub fn cancel_b_from_a(self) -> ParallelWorkflow<A, B, Completed, Canceled>

Fires a cancellation event from Branch A that targets Branch B. This transition consumes the active BranchToken<B, Running> and returns a BranchToken<B, Canceled> token. Because the running token is consumed and cannot be cloned, Branch B can never be completed.

§Examples
use wasm4pm_compat::workflow::{ParallelWorkflow, Pending, Running, Completed, Canceled};

struct TaskA;
struct TaskB;
let workflow: ParallelWorkflow<TaskA, TaskB, Pending, Pending> = ParallelWorkflow::split();
// Start both branches
let workflow = ParallelWorkflow {
    branch_a: workflow.branch_a.start(),
    branch_b: workflow.branch_b.start(),
};
// Cancel Branch B from Branch A
let workflow: ParallelWorkflow<TaskA, TaskB, Completed, Canceled> = workflow.cancel_b_from_a();

Auto Trait Implementations§

§

impl<A, B, SA, SB> Freeze for ParallelWorkflow<A, B, SA, SB>

§

impl<A, B, SA, SB> RefUnwindSafe for ParallelWorkflow<A, B, SA, SB>

§

impl<A, B, SA, SB> Send for ParallelWorkflow<A, B, SA, SB>
where A: Send, SA: Send, B: Send, SB: Send,

§

impl<A, B, SA, SB> Sync for ParallelWorkflow<A, B, SA, SB>
where A: Sync, SA: Sync, B: Sync, SB: Sync,

§

impl<A, B, SA, SB> Unpin for ParallelWorkflow<A, B, SA, SB>
where A: Unpin, SA: Unpin, B: Unpin, SB: Unpin,

§

impl<A, B, SA, SB> UnsafeUnpin for ParallelWorkflow<A, B, SA, SB>

§

impl<A, B, SA, SB> UnwindSafe for ParallelWorkflow<A, B, SA, SB>
where A: UnwindSafe, SA: UnwindSafe, B: UnwindSafe, SB: 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> EvidenceKind for T

Source§

default fn kind_label(&self) -> &'static str

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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