High-level async coordination and synchronization primitives for fx: Queues, Hubs, Deferreds, Semaphores, Latches, and Refs.
High-level async coordination and synchronization primitives for fx: Queues, Hubs, Deferreds, Semaphores, Latches, and Refs.
(countdown-latch> count-or-prev)(countdown-latch> prev-effect count)Creates a countdown latch initialized with count.
Creates a countdown latch initialized with `count`.
(deferred-await>)(deferred-await> deferred-or-prev)(deferred-await> prev-or-deferred opts-or-deferred)(deferred-await> prev-effect deferred opts)Awaits completion of deferred and yields its value or propagates its failure.
Awaits completion of `deferred` and yields its value or propagates its failure.
(deferred-fail> deferred)(deferred-fail> deferred-or-prev err-or-deferred)(deferred-fail> prev-effect deferred failure-or-err)Completes deferred with a failure or error.
Completes `deferred` with a failure or error.
(deferred-succeed> deferred)(deferred-succeed> deferred-or-prev val-or-deferred)(deferred-succeed> prev-effect deferred value)Completes deferred successfully with value.
Completes `deferred` successfully with `value`.
(deferred>)(deferred> prev-effect)Creates a new uncompleted single-assignment IDeferred instance.
Creates a new uncompleted single-assignment `IDeferred` instance.
(hub-bounded>)(hub-bounded> capacity-or-prev)(hub-bounded> prev-effect capacity)Creates a broadcast Hub with bounded buffer capacity per subscriber.
Creates a broadcast Hub with bounded buffer capacity per subscriber.
(hub-publish> hub)(hub-publish> hub-or-prev item-or-hub)(hub-publish> prev-effect hub item)Publishes item to all active subscribers of hub. Returns count of subscribers.
Publishes `item` to all active subscribers of `hub`. Returns count of subscribers.
(hub-shutdown>)(hub-shutdown> hub-or-prev)(hub-shutdown> prev-effect hub)Closes hub and shuts down all active subscriber queues.
Closes `hub` and shuts down all active subscriber queues.
(hub-subscribe>)(hub-subscribe> hub-or-prev)(hub-subscribe> prev-effect hub)Subscribes to hub, returning a new subscription IQueue.
Subscribes to `hub`, returning a new subscription `IQueue`.
(hub-subscriber-count>)(hub-subscriber-count> hub-or-prev)(hub-subscriber-count> prev-effect hub)Returns the number of active subscriber queues for hub.
Returns the number of active subscriber queues for `hub`.
(hub-unsubscribe> hub sub-queue)(hub-unsubscribe> prev-effect hub sub-queue)Unsubscribes sub-queue from hub.
Unsubscribes `sub-queue` from `hub`.
(latch-await>)(latch-await> latch-or-prev)(latch-await> prev-or-latch timeout-or-latch)(latch-await> prev-effect latch timeout-ms)Awaits until latch count reaches 0 or timeout expires.
Awaits until `latch` count reaches 0 or timeout expires.
(latch-count-down>)(latch-count-down> latch-or-prev)(latch-count-down> prev-effect latch)Decrements the count of latch, releasing all awaiting callers when count reaches 0.
Decrements the count of `latch`, releasing all awaiting callers when count reaches 0.
(latch-get-count>)(latch-get-count> latch-or-prev)(latch-get-count> prev-effect latch)Returns the remaining count of latch.
Returns the remaining count of `latch`.
(make-deferred)Creates a new uncompleted IDeferred instance.
Creates a new uncompleted `IDeferred` instance.
(make-hub)(make-hub capacity)Creates an IHub instance with the specified buffer capacity per subscriber.
Creates an IHub instance with the specified buffer capacity per subscriber.
(make-latch count)Creates a countdown latch with initial count.
Creates a countdown latch with initial `count`.
(make-queue buffer-type capacity)Creates an IQueue instance with the specified buffer strategy.
Creates an IQueue instance with the specified buffer strategy.
(make-ref)(make-ref initial-val)Creates an IRef instance initialized with initial-val.
Creates an IRef instance initialized with `initial-val`.
(make-semaphore)(make-semaphore permits)Creates a counting semaphore with permits.
Creates a counting semaphore with `permits`.
(queue-bounded>)(queue-bounded> capacity-or-prev)(queue-bounded> prev-effect capacity)Creates a bounded effect queue with fixed capacity.
Creates a bounded effect queue with fixed capacity.
(queue-dropping>)(queue-dropping> capacity-or-prev)(queue-dropping> prev-effect capacity)Creates a dropping effect queue that drops newest elements when capacity is exceeded.
Creates a dropping effect queue that drops newest elements when capacity is exceeded.
(queue-offer> queue)(queue-offer> queue-or-prev item-or-queue)(queue-offer> prev-effect queue item)Offers item to queue. Returns boolean whether accepted.
Offers `item` to `queue`. Returns boolean whether accepted.
(queue-poll>)(queue-poll> queue-or-prev)(queue-poll> prev-effect queue)Takes an item immediately from queue without parking; returns nil if empty.
Takes an item immediately from `queue` without parking; returns nil if empty.
(queue-shutdown>)(queue-shutdown> queue-or-prev)(queue-shutdown> prev-effect queue)Closes queue, preventing new offers and waking waiting takers.
Closes `queue`, preventing new offers and waking waiting takers.
(queue-size>)(queue-size> queue-or-prev)(queue-size> prev-effect queue)Returns the current count of buffered elements in queue.
Returns the current count of buffered elements in `queue`.
(queue-sliding>)(queue-sliding> capacity-or-prev)(queue-sliding> prev-effect capacity)Creates a sliding effect queue that drops oldest elements when capacity is exceeded.
Creates a sliding effect queue that drops oldest elements when capacity is exceeded.
(queue-take>)(queue-take> queue-or-prev)(queue-take> prev-effect queue)Takes an item from queue, parking/blocking until an item is available.
Takes an item from `queue`, parking/blocking until an item is available.
(queue-unbounded>)(queue-unbounded> prev-effect)Creates an unbounded effect queue.
Creates an unbounded effect queue.
(ref-get>)(ref-get> ref-or-prev)(ref-get> prev-effect ref)Retrieves the current value of ref.
Retrieves the current value of `ref`.
(ref-set> ref)(ref-set> ref-or-prev val-or-ref)(ref-set> prev-effect ref new-val)Sets ref to new-val and yields new-val.
Sets `ref` to `new-val` and yields `new-val`.
(ref-update> ref f)(ref-update> prev-effect ref f)Atomically updates ref using function f and yields the new value.
Atomically updates `ref` using function `f` and yields the new value.
(ref>)(ref> initial-val-or-prev)(ref> prev-effect initial-val)Creates a thread-safe atomic effect state cell initialized with initial-val.
Creates a thread-safe atomic effect state cell initialized with `initial-val`.
(semaphore-acquire>)(semaphore-acquire> sem-or-prev)(semaphore-acquire> sem-or-prev n-or-sem)(semaphore-acquire> prev-effect sem n)Acquires n permits (default 1) from semaphore.
Acquires `n` permits (default 1) from semaphore.
(semaphore-available-permits>)(semaphore-available-permits> sem-or-prev)(semaphore-available-permits> prev-effect sem)Returns the number of permits currently available in semaphore.
Returns the number of permits currently available in semaphore.
(semaphore-release>)(semaphore-release> sem-or-prev)(semaphore-release> sem-or-prev n-or-sem)(semaphore-release> prev-effect sem n)Releases n permits (default 1) back to semaphore.
Releases `n` permits (default 1) back to semaphore.
(semaphore>)(semaphore> permits-or-prev)(semaphore> prev-effect permits)Creates a counting semaphore initialized with permits (default: 1).
Creates a counting semaphore initialized with `permits` (default: 1).
(with-permit> sem effect)(with-permit> sem n effect)Acquires n permits (default 1) from sem, runs effect in a protected resource bracket,
and guarantees release of permits upon completion, failure, or cancellation.
Acquires `n` permits (default 1) from `sem`, runs `effect` in a protected resource bracket, and guarantees release of permits upon completion, failure, or cancellation.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |