Structured concurrency, fibers, parallel combinators, and execution scopes for fx.
Structured concurrency, fibers, parallel combinators, and execution scopes for fx.
(all-par> effects)(all-par> a b)(all-par> prev-effect effects opts)Executes a collection of effects in parallel and returns a vector of results.
By default short-circuits (fail-fast) on first failure, cancelling peer fibers.
Options map:
:concurrency - maximum concurrent tasks (default: unbounded)
:fail-fast? - boolean whether to halt on first failure (default: true)
Executes a collection of effects in parallel and returns a vector of results. By default short-circuits (fail-fast) on first failure, cancelling peer fibers. Options map: `:concurrency` - maximum concurrent tasks (default: unbounded) `:fail-fast?` - boolean whether to halt on first failure (default: true)
(fiber-status>)(fiber-status> target-or-prev)(fiber-status> prev-effect target-fiber)Creates an effect that queries the status (:running, :succeeded, :failed, :interrupted) of fiber
or the currently executing fiber if none provided.
Creates an effect that queries the status (:running, :succeeded, :failed, :interrupted) of `fiber` or the currently executing fiber if none provided.
(fork> target-effect)(fork> prev-effect target-effect)Creates an effect that forks target-effect into a background fiber and yields the IFiber reference.
Supports threading upstream effect: (-> eff (fork>)) or standalone (fork> eff).
Creates an effect that forks `target-effect` into a background fiber and yields the `IFiber` reference. Supports threading upstream effect: `(-> eff (fork>))` or standalone `(fork> eff)`.
(interrupt>)(interrupt> target-or-prev)(interrupt> target-or-prev reason-or-target)(interrupt> prev-effect target-fiber reason)Creates an effect that interrupts fiber and cascades cancellation to all child fibers.
Creates an effect that interrupts `fiber` and cascades cancellation to all child fibers.
(join>)(join> target-or-prev)(join> prev-effect target-or-opts)Creates an effect that awaits completion of fiber and yields its outcome or propagates failure.
Optional opts map may contain :timeout-ms and :timeout-val.
Creates an effect that awaits completion of `fiber` and yields its outcome or propagates failure. Optional `opts` map may contain `:timeout-ms` and `:timeout-val`.
(map-par> f)(map-par> a b)(map-par> a b c)(map-par> prev-effect f coll opts)Applies effect-producing function f concurrently across elements in coll and collects results.
Options map:
:concurrency - maximum concurrent executions (default: unbounded / worker pool)
:fail-fast? - boolean whether to cancel peer tasks on failure (default: true)
Examples: (map-par> (fn [x] (fetch-item> x)) item-ids {:concurrency 4}) (-> items (map-par> (fn [x] (process> x)) {:concurrency 2}))
Applies effect-producing function `f` concurrently across elements in `coll` and collects results.
Options map:
`:concurrency` - maximum concurrent executions (default: unbounded / worker pool)
`:fail-fast?` - boolean whether to cancel peer tasks on failure (default: true)
Examples:
(map-par> (fn [x] (fetch-item> x)) item-ids {:concurrency 4})
(-> items (map-par> (fn [x] (process> x)) {:concurrency 2}))(race> effects)(race> prev-effect effects)Races a collection of effects concurrently, returning the outcome of the first successful effect and cancelling all other competitors. If all fail, yields the final failure.
Races a collection of effects concurrently, returning the outcome of the first successful effect and cancelling all other competitors. If all fail, yields the final failure.
(with-go> target-effect)(with-go> prev-effect target-effect)Scopes execution of effect to core.async go-routines.
Scopes execution of `effect` to `core.async` go-routines.
(with-thread-pool> executor-or-eff)(with-thread-pool> prev-or-exec target-or-exec)(with-thread-pool> prev-effect executor target-effect)Scopes execution of effect to an explicit Java ExecutorService or fixed thread pool.
Scopes execution of `effect` to an explicit Java `ExecutorService` or fixed thread pool.
(with-virtual-threads> target-effect)(with-virtual-threads> prev-effect target-effect)Scopes execution of effect to Java Virtual Threads.
Scopes execution of `effect` to Java Virtual Threads.
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 |