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

error send

error Стандарт: [§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✓ проверяется в 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✓ проверяется в 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 · Версия документации 1.0.0-beta© OxwaldLink · сгенерировано из Стандарта, исходников std и руководства