data Arc
Atomically counted pointer; T must be frozen or sync to be shared between tasks (§7.3).
Example:
fn length(xs: Shared<List<i64>>) -> usize pure => xs.len()
fn main() io {
let shared = freeze([1, 2, 3])
let copy = shared.clone()
scope {
let h = spawn length(copy)
print("{h.join()!} {shared.len()}")
}
}Output
3 3
@builtin("Arc") pub(api) data Arc<T>Thread safety. safe to share when `T` is `frozen`.
Since. 1.0.0-beta
Methods
new | (value: T) -> Arc<T>A new atomically counted pointer to value. |
clone | () -> Arc<T>Another pointer to the same value (the count grows by one). |
Defined in: std/core/types.oxl:556