No matching definitions.

tur/barrier

stdlib/barrier.tur

counting barrier: N threads rendezvous, then all proceed.

(let [b (barrier-new 3)]
    ;; ... three threads each call (barrier-wait b) ...
    (barrier-free b))

Since: 2026-08-20

defopaque linear

Barrier

(Barrier)
defn

barrier-new

(barrier-new [n : int] :)

create a barrier that releases every n-th waiter.

nnumber of threads that must rendezvous; must be >= 1

A Barrier handle. Free it with barrier-free.

(let [b (barrier-new 3)] (barrier-free b))

Since: 2026-08-20

defn

barrier-wait

(barrier-wait [^borrow b : Barrier] :)

block until n threads have arrived, then release them all.

bthe Barrier to wait on (borrowed)

true for exactly ONE of the n threads released -- the one whose arrival tripped the barrier -- and false for the rest. Mirrors PTHREAD_BARRIER_SERIAL_THREAD, and is what lets a single thread run the between-phases work (swap buffers, print a summary) with no extra lock.

(if (barrier-wait b) (println "phase done") 0)

Since: 2026-08-20

defn

barrier-free

(barrier-free [b : Barrier] :)

destroy the barrier and release its memory.

bthe Barrier to destroy (consumed)
(barrier-free b)

Since: 2026-08-20

Internal definitions