Skip to content

Activity Implicit fork and join

Mikołaj Milewski edited this page Oct 27, 2026 · 1 revision

Implicit Fork and Join

Stateflows Activity nodes can reuse tokens across outgoing flows or wait for input from multiple incoming flows without explicit Fork and Join Nodes. These are node activation options, not additional visible nodes. Prefer explicit nodes when the branching or synchronization should be clear in the UML graph.

flowchart LR
    left(Produce A) --> join(Action with implicit join)
    right(Produce B) --> join
    join --> fork(Action with implicit fork)
    fork --> one(Consumer 1)
    fork --> two(Consumer 2)
Loading

Mermaid approximation: this diagram shows the model's routing, not a complete UML Activity notation. Rounded boxes represent actions; edge labels identify token types or guards. Mermaid does not provide native Activity node semantics.

.AddInitial(initial => initial
    .AddControlFlow("ProduceA")
    .AddControlFlow("ProduceB"))
.AddAction(
    "ProduceA",
    async c => c.Output(10),
    node => node.AddFlow<int>("Combine"))
.AddAction(
    "ProduceB",
    async c => c.Output(20),
    node => node.AddFlow<int>("Combine"))
.AddAction(
    "Combine",
    async c => c.Output(c.GetTokensOfType<int>().Sum()),
    node => node
        .AddFlow<int>("WriteAudit")
        .AddFlow<int>("UpdateDashboard"))
.AddAction("WriteAudit", async c =>
    await audit.WriteAsync(c.GetTokensOfType<int>().Single(), c.CancellationToken))
.AddAction("UpdateDashboard", async c =>
    await dashboard.UpdateAsync(c.GetTokensOfType<int>().Single(), c.CancellationToken))

Combine uses the Action Node defaults: its implicit join waits for both streams, and its implicit fork permits the emitted result to reach both consumers. To express a visible synchronization or fan-out point instead, insert explicit Join and Fork Nodes.

Implicit join

With NodeOptions.ImplicitJoin, a node waits until the required incoming flow streams are available before activating. Without it, an available incoming stream can activate the node. This is not identical to an explicit Join Node, which represents synchronization as a separate model element.

Implicit fork

With NodeOptions.ImplicitFork, a token can remain available for multiple matching outgoing flows. Without it, a token consumed by a selected outgoing flow is removed from the source node's remaining output tokens. Use an explicit Fork Node when the graph should show a deliberate fan-out.

Defaults

Node kind Default options
Action ImplicitJoin and ImplicitFork
Decision ImplicitJoin
Data Store ImplicitFork
Other control nodes None

Builders exposing node options can remove defaults with NoImplicitJoin() or NoImplicitFork(), or set options directly with SetOptions(...). Options affect execution semantics: change them only when the graph requires different token handling. See Nodes, Flows, and Tokens.

Overview
Installation
Runtimes
   Orleans runtime
Concepts
   Events and Structural Events
   Messaging Patterns
   Validation
   Scheduling
   Observability
Behaviors
   Behavior Values
   Dependency Injection
   Behavioral Groups
   State Machines
       Concepts
           State Identity
           In-State Event Deferrals
           Evaluation of Transitions
           Exception Handling
       Building blocks
           Regions
           States
               State
               Composite State
               Orthogonal State
               Final State
           Pseudostates
               Choice
               Junction
               Fork
               Join
               History
           Transitions
               Transition
               Default Transition
               Internal Transition
   Activities
       Concepts
           Exception Handling
           Implicit Fork and Join
           Tokens
       Building blocks
           Nodes
               Action Node
               Decision Node
               Merge Node
               Initial Node
               Final Node
               Input Node
               Output Node
               Fork Node
               Join Node
               Accept Event Action Node
               Send Event Action Node
               Publish Event Action Node
               Time Event Action Node
               Data Store Node
               Structured Activity Node
               Iterative Activity Node
               Parallel Activity Node
           Flows
               Data Flow
               Control Flow
   Actions
   Entities
       Fields
       Mutations
       Projections
Extensions
   ClearScript
   FluentValidation
   JSON definitions
   Minimal APIs
   OneOf
   OpenTelemetry
   PlantUML
   Scheduling

Clone this wiki locally