OxL Справочник OxL
РусскийEnglish

data Handle

Handle of a spawned task (§8.3).

Example:

oxl✓ проверяется в CI
fn work(n: i64) -> i64 time {
  sleep(10ms)
  n + 1
}

fn main() io, time {
  scope {
    let h = spawn work(1)
    print("{h.join()!}")
  }
}
Вывод
2
@builtin("Handle") pub(api) data Handle<T, E>

Потокобезопасность. `join` and `cancel` may be called from the task that owns the scope.

С версии. 1.0.0-beta

Методы

join() -> T | E | Cancelled
Waits for the task
cancel()
Requests cooperative cancellation (§8.6).

Определено в: std/core/types.oxl:417

См. также