Race Expression
The race expression is used to run a block of two or more async expressions concurrently (simultaneously). When the fastest expression completes, it “wins the race”. Any remaining “losing” expressions are canceled, then any expression that follows the race is evaluated.
| | |
| --- | --- |
| | set WinnerResult = race: |
| | # All three async functions start at the same time |
| | AsyncFunctionLongTime() |
| | AsyncFunctionShortTime() # This will win and its result is used |
| | AsyncFunctionMediumTime() |
| | # Next expression is called after the fastest async function completes |
| | # / when the fastest/shortest async function task (AsyncFunctionShortTime()) completes |
| | # and all other async function tasks (AsyncFunctionLongTime(), AsyncFunctionMediumTime()) are canceled. |
| | NextExpression(WinnerResult) |
set WinnerResult = race:
All three async functions start at the same time
AsyncFunctionLongTime() AsyncFunctionShortTime() # This will win and its result is used AsyncFunctionMediumTime()
Next expression is called after the fastest async function completes
/ when the fastest/shortest async function task (AsyncFunctionShortTime()) completes
and all other async function tasks (AsyncFunctionLongTime(), AsyncFunctionMediumTime()) are canceled.
NextExpression(WinnerResult)
You're reading a preview
The full reference is free for BrainDeadGuild Discord members — sign in to read it all, or open the original at the source.
Sign in with your BrainDead.TV / BrainDeadGuild Discord account for full access.