OxL Reference

error task-reuse

error Standard: [§8.3]

What it means#

A Task is movable and single-use: exactly one operation consumes it (await, spawn, a combinator or starting a chain) (§8.3). Awaiting or spawning the same task a second time is a use of a moved value.

Example#

oxl✓ checked in CI
fn compute() -> i32 => 1

fn main() io, time {
  let t = Task.of { compute() }
  let a = await t
  let b = await t      // <- task-reuse
  print("{a} {b}")
}
error
task-reuse

How to fix#

oxl✓ checked in CI
fn compute() -> i32 => 1

fn main() io, time {
  let a = await Task.of { compute() }
  let b = await Task.of { compute() }
  print("{a} {b}")
}

Create a fresh task for every run, or keep the result of the first await and reuse that value.

See also#

OxL 1.0.0-beta · Documentation version 1.0.0-beta© OxwaldLink · generated from the Standard, the std sources and the guides