net.core.async
Small extensions and improvements on top of core.async
Some bits shamelessly stolen from @mpenet’s jet, See https://github.com/mpenet/jet for original
put!
(put! ch msg backpressure! close!)
(put! ch msg backpressure!)
Takes a ch
, a msg
, a single arg function that when passed true
enables backpressure and when passed false
disables it, and a no-arg function which, when invoked, closes the upstream source.
timeout-pipe
(timeout-pipe max-wait from to close?)
(timeout-pipe tmval from to)
A variation on clojure.core.async/pipe
which will close if no input is submitted within a given interval.
validating-chan
(validating-chan spec buf-or-n error-value always-assert?)
(validating-chan spec buf-or-n error-value)
(validating-chan spec buf-or-n)
A chan which ensures that values produced to it match a given spec. Failing to match the spec will produce error-value
on the channel.
When error-value
is a function, call it with no args to produce the error value, or produce error-value
itself.
When always-assert?
is provided, force asserts, regardless of the value of *clojure.core/compile-asserts*
, otherwise, and by default honor the value.
The 1-arity version produces nil on the chan in case of errors.
validating-fn
(validating-fn spec always-assert?)
Yield correct predicate based on assertion preference.
validating-promise-chan
(validating-promise-chan spec error-value always-assert?)
(validating-promise-chan spec error-value)
(validating-promise-chan spec)
A promise chan which ensures that values produced to it match a given spec. Failing to match the spec will produce error-value
on the channel.
When error-value
is a function, call it with no args to produce the error value, or produce error-value
itself.
When always-assert?
is provided, force asserts, regardless of the value of *clojure.core/compile-asserts*
, otherwise, and by default honor the value.
The 1-arity version produces nil on the chan in case of errors.