Liking cljdoc? Tell your friends :D

fx.async.coordination

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.
raw docstring

countdown-latch>clj/s

(countdown-latch> count-or-prev)
(countdown-latch> prev-effect count)

Creates a countdown latch initialized with count.

Creates a countdown latch initialized with `count`.
raw docstring

deferred-await>clj/s

(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.
raw docstring

deferred-fail>clj/s

(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.
raw docstring

deferred-succeed>clj/s

(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`.
raw docstring

deferred>clj/s

(deferred>)
(deferred> prev-effect)

Creates a new uncompleted single-assignment IDeferred instance.

Creates a new uncompleted single-assignment `IDeferred` instance.
raw docstring

hub-bounded>clj/s

(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.
raw docstring

hub-publish>clj/s

(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.
raw docstring

hub-shutdown>clj/s

(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.
raw docstring

hub-subscribe>clj/s

(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`.
raw docstring

hub-subscriber-count>clj/s

(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`.
raw docstring

hub-unsubscribe>clj/s

(hub-unsubscribe> hub sub-queue)
(hub-unsubscribe> prev-effect hub sub-queue)

Unsubscribes sub-queue from hub.

Unsubscribes `sub-queue` from `hub`.
raw docstring

latch-await>clj/s

(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.
raw docstring

latch-count-down>clj/s

(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.
raw docstring

latch-get-count>clj/s

(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`.
raw docstring

make-deferredclj/s

(make-deferred)

Creates a new uncompleted IDeferred instance.

Creates a new uncompleted `IDeferred` instance.
raw docstring

make-hubclj/s

(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.
raw docstring

make-latchclj/s

(make-latch count)

Creates a countdown latch with initial count.

Creates a countdown latch with initial `count`.
raw docstring

make-queueclj/s

(make-queue buffer-type capacity)

Creates an IQueue instance with the specified buffer strategy.

Creates an IQueue instance with the specified buffer strategy.
raw docstring

make-refclj/s

(make-ref)
(make-ref initial-val)

Creates an IRef instance initialized with initial-val.

Creates an IRef instance initialized with `initial-val`.
raw docstring

make-semaphoreclj/s

(make-semaphore)
(make-semaphore permits)

Creates a counting semaphore with permits.

Creates a counting semaphore with `permits`.
raw docstring

queue-bounded>clj/s

(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.
raw docstring

queue-dropping>clj/s

(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.
raw docstring

queue-offer>clj/s

(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.
raw docstring

queue-poll>clj/s

(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.
raw docstring

queue-shutdown>clj/s

(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.
raw docstring

queue-size>clj/s

(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`.
raw docstring

queue-sliding>clj/s

(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.
raw docstring

queue-take>clj/s

(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.
raw docstring

queue-unbounded>clj/s

(queue-unbounded>)
(queue-unbounded> prev-effect)

Creates an unbounded effect queue.

Creates an unbounded effect queue.
raw docstring

ref-get>clj/s

(ref-get>)
(ref-get> ref-or-prev)
(ref-get> prev-effect ref)

Retrieves the current value of ref.

Retrieves the current value of `ref`.
raw docstring

ref-set>clj/s

(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`.
raw docstring

ref-update>clj/s

(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.
raw docstring

ref>clj/s

(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`.
raw docstring

semaphore-acquire>clj/s

(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.
raw docstring

semaphore-available-permits>clj/s

(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.
raw docstring

semaphore-release>clj/s

(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.
raw docstring

semaphore>clj/s

(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).
raw docstring

with-permit>clj/s

(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.
raw 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