← Back to the index

Module std/sync.vv

The sync module provides basic synchronization primitives such as mutual exclusion locks.

Example:

import sync from "std/sync.vv"
let m = sync.mutex()
sync.lock(m)
defer sync.unlock(m)

Table of Contents

Exports

fun mutex() extern "native"

Creates a new mutex.

Example:

let m = sync.mutex()

fun lock(m) extern "native"

Locks the mutex m. If the lock is already in use, the calling task blocks until the mutex is available.

Example:

sync.lock(m)

fun unlock(m) extern "native"

Unlocks the mutex m.

Example:

sync.unlock(m)