Skip to content

Deferred choice: the first branch whose wait goes on wins - #138

Merged
noha merged 1 commit into
mainfrom
deferred-choice
Sep 10, 2026
Merged

noha merged 1 commit into
mainfrom
deferred-choice

Conversation

@noha

@noha noha commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

FBDeferredChoice is a split whose branches each lead into a waiting spot - a condition wait, a trigger target, a remote flow, a sub flow call - and of which exactly one goes on: the first one whose wait is resumed. The others fall the moment the choice is decided, queued or parked, standing in a loop or a sub flow, in this instance or one executing inside it. An FBDeferredChoiceDecided records the winner.

The decision is made where a wait goes on, in the one continuation path FBBaseExecutor>>resume:withToken:value:, before the wait is taken out; a condition wait whose condition holds at once and a sub flow call that runs through decide it as well. A pass remembers its origin token and whether it was decided. A branch that could not wait is refused when the choice runs.

A withdrawal now takes the tokens of standing activations too - a fork whose loop is open, a sub flow node whose child runs - when they lie on the strand taken back: the loop starts nothing more and the frame pops quietly, the call reading #cancelled. cancelStrand: into a sub flow thus ends the call instead of failing the caller.

FBDeferredChoice is a split whose branches each lead into a waiting
spot - a condition wait, a trigger target, a remote flow, a sub flow
call - and of which exactly one goes on: the first one whose wait is
resumed. The others fall the moment the choice is decided, queued or
parked, standing in a loop or a sub flow, in this instance or one
executing inside it. An FBDeferredChoiceDecided records the winner.

The decision is made where a wait goes on, in the one continuation
path FBBaseExecutor>>resume:withToken:value:, before the wait is taken
out; a condition wait whose condition holds at once and a sub flow
call that runs through decide it as well. A pass remembers its origin
token and whether it was decided. A branch that could not wait is
refused when the choice runs.

A withdrawal now takes the tokens of standing activations too - a
fork whose loop is open, a sub flow node whose child runs - when they
lie on the strand taken back: the loop starts nothing more and the
frame pops quietly, the call reading #cancelled. cancelStrand: into a
sub flow thus ends the call instead of failing the caller.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@noha
noha merged commit 1087d2f into main Sep 10, 2026
4 checks passed
@noha
noha deleted the deferred-choice branch September 10, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant