-
Notifications
You must be signed in to change notification settings - Fork 0
sendTo
Scheduler Management / Thread Safety
Binary — <array> sendTo <schedulerId>.
<array> sendTo <number>
Transfers ownership of an array to another scheduler. The array is moved from the current scheduler's ownership to the target scheduler. Returns a new array reference that is valid on the target scheduler.
After transfer, the original array reference is invalidated — accessing it from the original scheduler will throw an ownership error.
Marks the array's ownership as transferred to the target scheduler. The array's data is not copied — this is a transfer of ownership, not a copy. The target scheduler can then freely mutate the array. The source scheduler loses access.
_arr = [1, 2, 3, 4, 5];
_arr sendTo 2; // array now owned by scheduler 2
// _arr is now INVALID on this scheduler// Scheduler 1: prepare data
_data = collectGameState(); // builds array
_data sendTo 2; // transfer to AI scheduler
// Scheduler 2 (via spawnOn): receive and process
// (the transfer must be coordinated via other means —
// typically the array reference is passed via spawnOn args)_data = [1, 2, 3];
// freeze for safe cross-scheduler sharing:
_frozen = freeze _data;
[freeze _data] spawnOn ["AI", {
params ["_frozenData"];
_local = thaw _frozenData;
_local pushBack 4; // mutate local copy
}];_targetId = 2;
if (schedulerExists _targetId) then {
_data sendTo _targetId;
} else {
systemChat "Target scheduler does not exist";
};Thread-safe transfer mechanism. The ownership change is atomic — no other fiber can access the array during the transfer window. After transfer, the source scheduler's reference is invalidated.
- freeze — safer cross-scheduler sharing (immutable snapshot)
- thaw — create mutable copy from frozen
- scheduler — get value's owner
- isSchedulerLocal — check ownership
- spawnOn — spawn on target 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