Alpha, subject to change without notice! Runner util for easily configurable a/sync fn execution. Compared to agents: - Runners have (configurable) back-pressure mechanism. - Runners may be non-linear when n-threads > 1. - Runners take nullary fns rather than unary fns of state. - Runners have no validators or watches. - Runners auto shutdown their threads on JVM shutdown.
(runner {:keys [mode buffer-size n-threads thread-name daemon-threads?]
:as opts
:or {mode :sliding buffer-size 1024 n-threads 1}})Returns a new stateful (fn runner ([]) ([f])) such that:
(runner f) => Runner should execute given nullary fn according to runner opts.
Returns:
nil if runner has stopped accepting new execution requests.
true if fn was accepted for execution *without* back pressure.
false if runner's back-pressure mechanism was engaged.
(runner) => Runner should stop accepting new execution requests.
Returns true iff runner's status changed with this call.
Runners are a little like simplified agents with an explicit and configurable
back-pressure mechanism.
Options include:
`mode` - Mode of operation, ∈ #{:sync :blocking :dropping :sliding}.
`buffer-size` - Size of buffer before back-pressure mechanism is engaged.
`n-threads` - Number of threads for asynchronously executing fns.
NB execution order may be non-sequential when n > 1.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 |