-
Notifications
You must be signed in to change notification settings - Fork 0
timeout
ffredyk edited this page Jul 23, 2026
·
1 revision
Concurrency
Binary — <handle> timeout <seconds>.
<scriptHandle> timeout <number>
Races a ScriptHandle against a time limit. Returns a new ScriptHandle that resolves when either the original handle completes or the timeout expires — whichever happens first.
- If the original handle completes before timeout → new handle resolves with the original's return value.
- If timeout expires first → new handle resolves with
nil(original may still be running).
The original handle is not automatically terminated — use terminate if needed.
Creates a composite handle that monitors both the original handle's resolution and a timer. The first to trigger resolves the composite handle. The original handle continues running even if timeout fires (unless explicitly terminated).
_handle = spawn { sleep 10; return "slow result"; };
_race = _handle timeout 3; // 3 second timeout
_result = await _race;
// _result is nil (timeout fired first)
// _handle is still running!_handle = spawn { riskyOperation(); };
_race = _handle timeout 5;
_result = await _race;
if (isNil "_result") then {
terminate _handle; // stop the original
systemChat "Operation timed out";
} else {
systemChat f"Result: {_result}";
};_request = spawn { fetchFromServer(); };
_response = await (_request timeout 10);
if (isNil "_response") then {
terminate _request;
systemChat "Server not responding";
};_h1 = spawn { task1(); };
_h2 = spawn { task2(); };
_r1 = await (_h1 timeout 5);
_r2 = await (_h2 timeout 5);
if (isNil "_r1" || isNil "_r2") then {
systemChat "Some tasks timed out";
};Creates a new handle on the current scheduler. The original handle continues on its scheduler.
- Getting Started
- Language Guide
- Type System
- Control Flow
- Functions & Code
- Strings & Text
- Arrays & Collections
- Concurrency
- Promise System
- Thread Safety
- Host API & Embedding
- CLI Tool
- Bytecode Reference
- Multiplayer
- Syntax Sugar
- Optimization Guide
- Benchmarks
- count
- select
- pushBack
- append
- deleteAt
- deleteRange
- resize
- reverse
- sort
- find
- in
- forEach
- freeze
- thaw
- isFrozen
- currentScheduler
- clientOwner
- allSchedulers
- schedulerName
- schedulerExists
- schedulerBudget
- setSchedulerBudget
- fiberCount
- readyFiberCount
- waitingFiberCount
- schedulerLoad
- sendTo