- scope s { … }: task.scope.begin, task.scope.end at every normal exit
(scope ends generalized: borrow.end or task.scope.end, innermost first)
- task.spawn(s, f, args): call-like; named linear values moved (E7003);
lent borrows are bound first (inline borrow E7006); scope operand E7005
- task.join/cancel/cancelled; task<T>, sender<T>, receiver<T>, scope types
- channels: make<T>, dup, send, recv, close_sender, close_receiver; send,
recv and close_receiver are outcome matches; endpoints by name, borrowed
for the operation and ended on every edge (written `mut tx`: E7006)
- outcome rebinding: a value coming back under the name of a variable of
its type becomes the variable's value (pending(r))
- joins carry live variables only (pruned SSA): a linear value consumed
before a join does not travel to it; ordered after-walk over the
enclosing statement or tail, sibling arms not counted
- parser: a keyword after `.` is a member name (task.cancelled)
- conformance equivalence ignores schedule.choices (quantum counts AIR
instructions)
- tests: 10 run tests with AIR equivalence (Phase 3 programs), 12 rejects
(E4301, E4101 x2, E4002, E2001, E3101, E3002, E7006 x2, E7003, E0006,
E7005); Quick Reference tasks/channels programs now pass
- spec 15 §4/§6/§7, grammar, quick reference, bundle notes, plan
31 lines
590 B
Rust
31 lines
590 B
Rust
// The same shared borrow of Share data is lent to two tasks.
|
|
// expect: run
|
|
// schedules: 10
|
|
// result: 42
|
|
// equivalent: phase3/run/tasks_shared_read.air
|
|
// phase: 6
|
|
// spec: docs/spec/15-source-language.md
|
|
module demo.sharedread
|
|
|
|
fn read(p: ref<u64>) -> u64
|
|
effects []
|
|
{
|
|
*p
|
|
}
|
|
|
|
fn main() -> u64
|
|
effects [task.spawn]
|
|
{
|
|
var x: u64 = 21;
|
|
ref r = x;
|
|
var sum: u64 = 0;
|
|
scope sc {
|
|
let t1 = task.spawn(sc, read, r);
|
|
let t2 = task.spawn(sc, read, r);
|
|
let a = task.join(move t1);
|
|
let b = task.join(move t2);
|
|
sum = a + b;
|
|
}
|
|
sum
|
|
}
|