Skip to content

currentScheduler

ffredyk edited this page Jul 23, 2026 · 1 revision

currentScheduler

Category

Scheduler Management

Arity

NularcurrentScheduler.

currentScheduler

Description

Returns the numeric ID of the scheduler that the current fiber is running on. Every scheduler has a unique integer ID assigned at creation. Use for debugging, conditional logic, and scheduler-specific operations.

How It Works

Reads the scheduler ID from the current VM execution context. This is a VM-level built-in command. O(1).

Usage

Identify current scheduler

_id = currentScheduler;        // e.g., 1
systemChat f"Running on scheduler {_id}";

Conditional by scheduler

if (currentScheduler == 1) then {
    // running on Main scheduler
    updateUI();
} else {
    // running on worker scheduler
    doBackgroundWork();
};

Scheduler info

_id = currentScheduler;
_name = schedulerName _id;     // "Main"
_budget = schedulerBudget _id; // 3.0 (ms)

Transfer ownership

_targetScheduler = 2;
if (currentScheduler != _targetScheduler) then {
    _arr sendTo _targetScheduler;
};

Thread Safety

ReadOnly — pure query. Safe from any scheduler.

See Also

SQ# Wiki

Home

Engine Docs

Migration

Commands

Value Constructors

Arithmetic

Comparison

Logic

Array

String

Math

Random

Type & Introspection

HashMap

Code Execution

Concurrency

Scheduler

Thread Safety

Error

Output

Time

Multiplayer

Compiler

Clone this wiki locally