On this page
Vibe concurrency
Vibe's concurrency is Verada's: library tasks and protected objects, written with the helpers below. Python's threads, async/await and multiprocessing are not Vibe. The shared concurrency and devices reference defines the actual synchronization, flow, and platform rules.
Protected classes and objects
Declare a module-level class directly based on Protected. Annotated fields become its protected state; methods become synchronized operations:
from verada import Natural, Protected, entry, when
class Buffer(Protected):
count: Natural = 0
@entry
def put(self) -> None:
when(self.count < 4)
self.count += 1
@entry
def get(self) -> int:
when(self.count > 0)
self.count -= 1
return int(self.count)
shared = Buffer()This is a declaration fragment illustrating barriers, not a complete producer/consumer application. The full tasking corpus uses a bounded ring and separate worker/main modules.
An entry must begin with when(condition) as its literal first statement; a docstring or ordinary statement before it prevents barrier recognition. The condition is the wait barrier, not a precondition the caller proves before making the call. The runtime blocks until the barrier opens and the protected action can execute. The entry's updates occur under the object's synchronization.
A protected operation can return a value. If it is an entry or changes protected components, the value uses the generated final output-result convention. The caller uses a typed assignment such as received: int = shared.get(). A read-only protected function has its ordinary result. Put related state behind the same protected object rather than sharing an ordinary mutable module variable between tasks.
Create an object with a no-argument module assignment shared = Buffer(). A protected object is not copied: every task that names shared uses the one object.
Tasks
An exact @task decoration on a module-level function introduces a library task and its body. Use no parameters and -> None:
from verada import sleep, task
@task
def producer() -> None:
while True:
sleep(1.0)This fragment is deliberately a persistent task; a complete application needs the intended work and shutdown behavior. A task begins after library elaboration, alongside the main program and other tasks. Calling it like an ordinary Python function is not the startup mechanism. The native program waits for its tasks after the main returns.
sleep(seconds) is a relative delay. stop() invokes Verada.Tasking.Stop: the POSIX runtime requests cancellation of the other task threads and calls pthread_exit when the caller is itself a task. Cancellation is deferred until a thread reaches a cancellation point; a CPU-bound task without one may continue, leaving the main thread waiting in its joins. This is a cancellation request, not a proved guarantee of bounded or completed shutdown. Use it deliberately for application-wide shutdown, not as a local break. The corpus's waiting workers reach delay/wait operations compatible with that mechanism.
Tasks communicate through protected objects; Verada has no rendezvous, select, abort or requeue. Task types, priorities and absolute delays are declared in Vada or Varc and imported.
What checking and proof establish
Verada checks shared effects for data races, potentially blocking calls inside protected actions, and applicable priority/ceiling constraints. Calls through a supported operation are analyzed transitively. A protected action must not reach a delay or entry call that can block while it holds its lock. Ordinary scalar and contract proof applies inside task bodies and operations under the shared tasking model.
These properties do not establish fairness, arbitrary liveness, bounded response time, or real-time scheduling on every platform. Standard output is shared state for flow analysis; do not assume multiple tasks may print just because runtime output routines use a lock. Design one printing task or a proved protected communication path.
The runtime uses POSIX threads, and its tables of tasks and protected locks grow as the program elaborates them. macOS does not supply the priority scheduling a real-time target implies, so priority values do not order execution there.
Device and Python boundaries
Vibe has no general decorator/annotation for every volatile/external/address aspect. Use a validated imported wrapper that states its contracts and external assumptions when integrating device registers or C. Reading asynchronous state needs the shared whole-value and non-interference rules, not Python's ordinary repeated property access model.
CPython's plain function/method execution cannot reproduce a protected entry barrier or a task activated by compiler elaboration. The repository marks its tasking corpus inapplicable to that oracle. A stub's @task, @entry, when, or sleep signature does not implement a Python runtime scheduler. Do not run the example under a test shim and treat it as a concurrency proof.
Source evidence: task/protected lowering, tasking flow analysis, runtime, and complete worker example.