No matching definitions.

thread-pool/pool

src/thread-pool/pool.tur

bounded POSIX worker-thread pool with a typed,

Since: TP1 (typed/linear surface since TP2)

defopaque

Pool

(Pool [T] :ptr<void>)

an opaque, linear worker-pool handle parameterised by its work-item

Since: TP2

defn

pool-new

(pool-new [T])

allocate a bounded worker pool with a typed callback.

sizenumber of worker threads (clamped to >= 1).
callback(fn [T] void) invoked on each dequeued item. Receives the
item by value and owns it (the submitter loses access on
submit). Must remain valid for the full lifetime of the
poolbind it in a scope that outlives pool-stop.

A linear (Pool T) handle. pool-new aborts on the (rare) allocation / spawn failure rather than handing back a null linear handle.

(let [p (pool-new 8 (fn [x : int] : void (consume x)))]
    (pool-submit p 1)
    (pool-stop p))

Since: TP2

defn

pool-submit

(pool-submit [T])

enqueue a typed work item; blocks when the ring is full.

poolborrowed (Pool T) handle.
iteman owned T, handed to the worker callback.

Since: TP2

defn

pool-stop

(pool-stop [T])

signal shutdown, drain queued items, join workers, free.

poolthe (Pool T) handle, consumed.

Since: TP2

defn

pool-try-submit

(pool-try-submit [T])

enqueue without blocking; report saturation instead.

poolborrowed (Pool T) handle.
iteman owned T.

Since: TP2

defn

pool-pending

(pool-pending [T])

number of items currently queued (read under the lock).

Since: TP2

defn

pool-workers

(pool-workers [T])

number of live worker threads.

Since: TP2

defn

pool-queue-cap

(pool-queue-cap [T])

ring-buffer capacity (max(size * 4, 64)).

Since: TP2

defn

pool-new-raw

(pool-new-raw [size : int callback ptr<void>] :)

allocate a pool driven by a raw `void (*)(void *item)` C

sizeworker count (clamped to >= 1).
callbackptr<void> holding a `void (*)(void *item)`.

Since: TP2 (was pool-new in TP1)

defn

pool-submit-raw

(pool-submit-raw [pool ptr<void> item ptr<void>] :)

enqueue a ptr<void> work item on a raw pool; blocks

Since: TP2 (was pool-submit in TP1)

defn

pool-stop-raw

(pool-stop-raw [pool ptr<void>] :)

drain, join, and free a raw pool. NULL is a no-op.

Since: TP2 (was pool-stop in TP1)

Internal definitions
pool-worker-loop-- (internal) thread entry; dequeues and dispatches items.
pool-try-enqueue