Concurrency
Planned structured concurrency, async/await, channels, actors, cancellation, and data-parallel execution.
Concurrency is documented as a Phase-0 design draft in .sources/vela/design/CONCURRENCY.md. The current Stage-0
examples do not implement async, await, channels, actors, task scopes, or supervisors.
1. Design goals
The planned model has three audiences:
- analysts get automatic data-parallelism from dataframe and broadcast execution,
- application writers get structured concurrency, async/await, channels, and actors,
- systems/library authors get opt-in ownership-tier control with
Send/Syncchecks.
The design rule is that safe Vela should not allow data races. Logical races and deadlocks can still be programmer concerns, but shared mutable memory is planned to require actors, channels, or synchronization types.
2. Current data-parallel shape in Stage-0 examples
Stage-0 already has vectorized broadcast syntax. The example notes that true single-loop fusion is planned for the compiler; the seed evaluates element-wise.
# Source: .sources/vela/examples/vectors.vela
xs = [1.0, 2.0, 3.0, 4.0, 5.0]
print("xs =", xs)
print("xs .* 2 =", xs .* 2.0)
print("xs .+ 100 =", xs .+ 100.0)
z = sqrt.(xs .^ 2.0 .+ 1.0)
print("sqrt(x^2 + 1) =", z)
print("sum =", xs |> sum)
print("mean =", xs |> mean)
print("max =", xs |> max)
3. Planned async and structured scopes
The design proposes:
async fnfor functions that can suspend,awaitas an explicit suspension and cancellation checkpoint,joinandselectas structured combinators,scopeblocks where spawned tasks cannot outlive the scope,- cancellation propagation through the task tree.
This syntax is planned and should be labeled as such until implemented.
4. Planned channels and actors
Channels are planned as typed, bounded-by-default message queues with backpressure. Actors are planned as isolated
state owners whose msg handlers run one at a time. The goal is to make shared mutable state safe without requiring
most users to reason about locks.
5. Planned cancellation model
Cancellation is designed to be cooperative and to surface at await points or explicit checkpoint() calls. The
scope model is intended to ensure cleanup runs and no task leaks past the block that spawned it.
6. Planned ownership checks
The design adopts Send and Sync marker-trait ideas:
Sendmeans ownership can move to another task/thread,Syncmeans shared references can be used across tasks,- non-atomic reference-counted handles are not planned to cross threads,
Arc,Mutex, channels, and actors are the planned shared-state tools.