OxL Reference

error send

error Standard: [§7.3]

What it means#

A value can cross a task boundary (spawn, a channel, an actor message) only if its type contains no Rc, no borrows, and no non-sync cells with interior mutability (§7.3). Sharing is done through Arc<frozen T> (freeze(x)) or Arc<T> with T: sync. This is what removes data races from safe code.

Example#

oxl✓ checked in CI
fn work(xs: Rc<List<i32>>) { }

fn main() io, time {
  scope {
    let xs = Rc.new([1, 2, 3])
    spawn work(xs)      // <- send
  }
}
error
send

How to fix#

oxl✓ checked in CI
fn work(xs: Arc<frozen List<i32>>) { }

fn main() io, time {
  scope {
    let xs = freeze([1, 2, 3])
    spawn work(xs)
  }
}

Replace Rc and borrows by owned values moved into the task, or by freeze(x) / a sync type for sharing.

See also#

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