Module scheduler
Prioritized Task Scheduling (src/page/bindings_scheduler.odin): scheduler.postTask / scheduler.yield, TaskController and TaskSignal. The priority queue and the ordering are native (on the page's event loop); the C glue holds each task's JavaScript promise, callback and signal and runs the callback when the host says the task is due. Three priorities, highest first: user-blocking, user-visible, background.
Exposed to: Window, Worker. Source: api/scheduler.widl.
Odin: import "wren:scheduler".
Types
enum TaskPriority : i32
A task priority (TaskPriority), highest first.
| member | value | |
|---|---|---|
User_Blocking | 0 | |
User_Visible | 1 | |
Background | 2 |
Functions
Scheduler_post
u64 Scheduler_post(u32 callback, i32 user, TaskPriority priority, f64 delay_ms)Post a task; callback (a function-table index) runs with (user: i32) when the task is due. delay_ms 0 queues
it at once. Returns the task id (for cancel / setPriority), 0 when there is no page realm.
Odin: scheduler.post.
Host: Scheduler_post :: proc(c: ^Call, callback: u32, user: i32, priority: Api_TaskPriority, delay_ms: f64) -> u64
Scheduler_cancel
void Scheduler_cancel(u64 id) raisesDrop a queued (or delayed) task: its signal aborted, or the realm released it.
Odin: scheduler.cancel.
Raises: returns an Error (see web).
Host: Scheduler_cancel :: proc(c: ^Call, id: u64) -> Api_Error
Scheduler_setPriority
void Scheduler_setPriority(u64 id, TaskPriority priority) raisesChange a queued task's priority (TaskController.setPriority).
Odin: scheduler.setPriority.
Raises: returns an Error (see web).
Host: Scheduler_setPriority :: proc(c: ^Call, id: u64, priority: Api_TaskPriority) -> Api_Error
Scheduler_isInputPending
bool Scheduler_isInputPending(bool include_continuous)navigator.scheduling.isInputPending.
Odin: scheduler.isInputPending.
Host: Scheduler_isInputPending :: proc(c: ^Call, include_continuous: bool) -> bool