envzn
0.8 · beta · not released

Library / Concurrency / Tasks and threads / Task

CLASS

Task

User-visible handle for a CONCURRENT-spawned task.

Constructors 1

INIT(REFERENCE String name)

Methods 3

METHOD name() RETURNS String
reads

PUBLIC API

METHOD isCancelled() RETURNS boolean
reads

Returns TRUE once the enclosing CONCURRENT scope has flipped this task's cancellation flag. Body code is expected to call this in any long-running loop and exit cooperatively.

METHOD sleep(int64 millis) RETURNS void
reads

Sleep the calling OS thread for millis milliseconds. Lowers to FOREIGN::ev_thread_sleep_ms(millis) → POSIX nanosleep in EV_unsafe_concurrency_native.cpp.

The receiver MUST be the current task: the analyzer rules against storing/passing Task handles ensure currentTask is the only reachable receiver. sleep does NOT observe the cancellation flag — callers that want cancellable sleep check isCancelled() before and after the call.