Systems

vthreading

Locks and atomic counters, built on spawn, await, share and protect.

Released v1.0.0 · 2026-09-28
Import
use "stdlib/threading.ven"
vthreading.ven
l = lock_new()
print lock_run(l, make() give 41 + 1)
:: 42
Reference (7 functions)

API reference

lock_new()

Builds a new, unlocked Lock handle.

l = lock_new()
lock_run(l, make() give 41 + 1)
:: 42

lock_run(l, work_fn)

Runs work_fn with l held, giving back its result.

l = lock_new()
lock_run(l, make() give 41 + 1)
:: 42

atomic_counter_new()

Builds a new atomic counter handle, starting at zero.

c = atomic_counter_new()
atomic_counter_increment(c)
atomic_counter_add(c, 5)
atomic_counter_value(c)
:: 6

atomic_counter_increment(counter)

Increments counter by one, under its own protection.

c = atomic_counter_new()
atomic_counter_increment(c)
atomic_counter_value(c)
:: 1

atomic_counter_add(counter, amount)

Adds amount to counter, under its own protection.

c = atomic_counter_new()
atomic_counter_add(c, 5)
atomic_counter_value(c)
:: 5

atomic_counter_value(counter)

Gives back counters current value, under its own protection.

c = atomic_counter_new()
atomic_counter_increment(c)
atomic_counter_add(c, 5)
atomic_counter_value(c)
:: 6

run_concurrently(work_fns)

Runs every function in work_fns concurrently, giving back their results in order.

run_concurrently([make() give 1 + 1, make() give 2 + 2, make() give 3 + 3])
:: [2, 4, 6]

Get notified when vthreading changes

Get notified about

New versions and security advisories.

New and updated packages, once a day.

News on the math model built in Venutian.