Liking cljdoc? Tell your friends :D

fractal.engine.concurrent

L0 · concurrency primitives (engine-free). with-deadline runs a body under a single wall-clock budget on a DAEMON thread, so a stuck provider call can neither block JVM exit nor be relied on to stop (an orphaned call may still run — and cost — after the deadline fires; documented, 07 §3).

Phase 3 adds the bounded fan-out primitive bounded-fanout (≤cap workers, a daemon pool, dynvar propagation via bound-fn, partial-failure-tolerant) + a semaphore/with-permit pair (the GLOBAL leaf governor). The recursion ns composes these; the engine semantics live there, not here.

L0 · concurrency primitives (engine-free). `with-deadline` runs a body under
a single wall-clock budget on a DAEMON thread, so a stuck provider call can
neither block JVM exit nor be relied on to stop (an orphaned call may still
run — and cost — after the deadline fires; documented, 07 §3).

Phase 3 adds the bounded fan-out primitive `bounded-fanout` (≤cap workers, a
daemon pool, dynvar propagation via `bound-fn`, partial-failure-tolerant) +
a `semaphore`/`with-permit` pair (the GLOBAL leaf governor). The recursion ns
composes these; the engine semantics live there, not here.
raw docstring

bounded-fanoutclj

(bounded-fanout prefix pool-size xs f)

Run (f idx x) over xs on a bounded daemon thread pool of ≤pool-size threads, PRESERVING input order. Partial failure NEVER throws: each slot is captured independently as a result map

{:ok true :index i :value v} | {:ok false :index i :error <ex-data-or-map>}

and the returned vector is sorted by :index (index-aligned to xs). bound-fn carries the caller thread's dynamic bindings (the host current-turn-id/current-step-id/current-eval-id, 03 §7) onto each worker so a fanned-out leaf/child stamps the invoking eval. The pool is daemon (JVM-exit-safe) and always shut down.

Run `(f idx x)` over `xs` on a bounded daemon thread pool of ≤`pool-size`
threads, PRESERVING input order. Partial failure NEVER throws: each slot is
captured independently as a result map

  {:ok true  :index i :value v}   | {:ok false :index i :error <ex-data-or-map>}

and the returned vector is sorted by `:index` (index-aligned to `xs`).
`bound-fn` carries the caller thread's dynamic bindings (the host
*current-turn-id*/*current-step-id*/*current-eval-id*, 03 §7) onto each
worker so a fanned-out leaf/child stamps the invoking eval. The pool is
daemon (JVM-exit-safe) and always shut down.
sourceraw docstring

semaphoreclj

(semaphore n)

A fair counting Semaphore of n permits, or nil (⇒ unbounded) for a nil/non-positive n.

A fair counting Semaphore of `n` permits, or nil (⇒ unbounded) for a
nil/non-positive `n`.
sourceraw docstring

with-deadlinecljmacro

(with-deadline timeout-ms & body)

Macro sugar: (with-deadline ms expr...)(with-deadline* ms (fn [] expr...)).

Macro sugar: `(with-deadline ms expr...)` ≡ `(with-deadline* ms (fn [] expr...))`.
sourceraw docstring

with-deadline*clj

(with-deadline* timeout-ms thunk)

Run thunk on a daemon thread under a timeout-ms wall-clock budget. Returns the thunk's value; re-throws its exception on the caller thread; on timeout throws ex-info {:error/type :fractal/deadline}. The worker is a daemon (JVM-exit-safe) and is interrupted as a courtesy when the deadline fires — but is never awaited (the call is orphaned).

Run `thunk` on a daemon thread under a `timeout-ms` wall-clock budget.
Returns the thunk's value; re-throws its exception on the caller thread; on
timeout throws `ex-info {:error/type :fractal/deadline}`. The worker is a
daemon (JVM-exit-safe) and is interrupted as a courtesy when the deadline
fires — but is never awaited (the call is orphaned).
sourceraw docstring

with-permitclj

(with-permit sem thunk)

Run thunk holding one permit from sem (nil ⇒ unbounded). Bounds the work INSIDE the thunk; the permit is always released.

Run `thunk` holding one permit from `sem` (nil ⇒ unbounded). Bounds the work
INSIDE the thunk; the permit is always released.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close