Skip to main content

sync

include "sync";

A lock for tasks that share data, so only one task changes it at a time.

Types​

Mutex​

Object

A lock for tasks. Tasks waiting for it get it in the order they asked. A task that holds the lock must not lock it again: it would wait forever. Create one with mutex_create.

FieldTypeWritableDescription
gatechannel<bool>yes

lock​

fn lock()

Waits until this task holds the lock.

unlock infallible​

infallible fn unlock()

Releases the lock.

guard​

fn guard(MutexBody body)

Runs body while holding the lock, and unlocks on success and failure.

Interfaces​

MutexBody​

Interface

Work that Mutex.guard runs while holding the lock.

run​

fn run()

Functions​

mutex_create​

fn mutex_create() -> Mutex

A new, unlocked Mutex.