Fanning out inside a system that is also doing its day job. Tasks in
data structures already run in parallel — (q/task {:a (f) :b (g)})
grounds both at once — and qfor maps in parallel when its body
spawns tasks. The recipe worth naming is the brake: a gate bounds
how many run at once, because an unbounded fan-out over production
data competes with production.
Fanning out inside a system that is also doing its day job. Tasks in
data structures already run in parallel — `(q/task {:a (f) :b (g)})`
grounds both at once — and `qfor` maps in parallel when its body
spawns tasks. The recipe worth naming is the brake: a `gate` bounds
how many run at once, because an unbounded fan-out over production
data competes with production.(gated n f coll)Run f (element → task) over coll with at most n in flight:
(gated 8 expensive-check ids) is the polite fan-out. Settles to
the results in collection order. The gate is a coordinator, not an
owner: the gated tasks stay structured under this eval, so cancelling
the eval cancels the enqueued work — running and queued alike —
nothing keeps running behind the brake, and the gate itself is
untouched.
Run `f` (element → task) over `coll` with at most `n` in flight: `(gated 8 expensive-check ids)` is the polite fan-out. Settles to the results in collection order. The gate is a coordinator, not an owner: the gated tasks stay structured under this eval, so cancelling the eval cancels the enqueued work — running and queued alike — nothing keeps running behind the brake, and the gate itself is untouched.
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 |