Liking cljdoc? Tell your friends :D

manifold.go-off

Provide a variant of core.async/go that works with manifold's deferreds and executors. Utilizes core.async's state-machine generator, so core.async must be provided as a dependency.

Provide a variant of `core.async/go` that works with manifold's deferreds and executors. Utilizes core.async's state-machine generator, so core.async must be provided as a dependency.
raw docstring

<!clj

(<! port)

Takes value from a deferred/stream. Must be called inside a (go ...) block. Will return nil if a stream is closed. Will park if nothing is available. If an error is thrown inside the body, that error will be placed as the return value.

N.B. To make go-off usage idiomatic with the rest of manifold, use <!? instead.

Takes value from a deferred/stream. Must be called inside a (go ...) block. Will
return nil if a stream is closed. Will park if nothing is available. If an error
is thrown inside the body, that error will be placed as the return value.

N.B. To make `go-off` usage idiomatic with the rest of manifold, use `<!?`
instead.
sourceraw docstring

<!?cljmacro

(<!? port)

Takes a val from a deferred/stream. Must be called inside a (go-off ...) block. Will park if nothing is available. If value that is returned is a Throwable, it will re-throw.

Takes a val from a deferred/stream. Must be called inside a (go-off ...) block.
Will park if nothing is available. If value that is returned is a Throwable,
it will re-throw.
sourceraw docstring

async-custom-terminatorsclj

source

go-offcljmacro

(go-off & body)

Asynchronously executes the body on manifold's default executor, returning immediately to the calling thread. Additionally, any visible calls to <!? and <! deferred operations within the body will block (if necessary) by 'parking' the calling thread rather than tying up an OS thread. Upon completion of the operation, the body will be resumed.

Returns a deferred which will receive the result of the body when completed. If the body returns a deferred, the result will be unwrapped until a non-deferrable value is available to be placed onto the return deferred.

This method is intended to be similar to core.async/go, and even utilizes the underlying state machine-related functions from core.async. It's been designed to address the following major points from core.async & vanilla manifold deferreds:

  • core.async/go assumes that all of your code is able to be purely async and will never block the handling threads. go-off removes the concept of handling threads, which means blocking is not an issue, but if you spawn too many of these you can create too many threads for the OS to handle.
  • core.async/go has no built-in way of handling exceptions and assumes all async code will be either written defensively, or have custom error propagation, which differs from how clojure code blocks typically work outside of the async world.
  • deferred/let-flow presumes that every deferrable needs to be resolved. This prevents more complex handling of parallelism or being able to pass deferreds into other functions from within the let-flow block.
  • deferred/chain only works with single deferreds, which means having to write code in unnatural ways to handle multiple deferreds.
Asynchronously executes the body on manifold's default executor, returning
immediately to the calling thread. Additionally, any visible calls to <!?
and <! deferred operations within the body will block (if necessary)
by 'parking' the calling thread rather than tying up an OS thread.
Upon completion of the operation, the body will be resumed.

Returns a deferred which will receive the result of the body when
completed. If the body returns a deferred, the result will be unwrapped
until a non-deferrable value is available to be placed onto the return deferred.

This method is intended to be similar to `core.async/go`, and even utilizes the
underlying state machine-related functions from `core.async`. It's been designed
to address the following major points from core.async & vanilla manifold deferreds:

- `core.async/go` assumes that all of your code is able to be purely async
and will never block the handling threads. go-off removes the concept of handling
threads, which means blocking is not an issue, but if you spawn too many of these you
can create too many threads for the OS to handle.
- `core.async/go` has no built-in way of handling exceptions and assumes all async
code will be either written defensively, or have custom error propagation, which
differs from how clojure code blocks typically work outside of the async world.
- `deferred/let-flow` presumes that every deferrable needs to be resolved. This prevents
more complex handling of parallelism or being able to pass deferreds into other functions
from within the `let-flow` block.
- `deferred/chain` only works with single deferreds, which means having to write code in
unnatural ways to handle multiple deferreds.
sourceraw docstring

go-off-withcljmacro

(go-off-with executor & body)

Implementation of go-off that allows specifying executor. See docstring of go-off for usage.

Implementation of go-off that allows specifying executor. See docstring of go-off for usage.
sourceraw docstring

return-deferredclj

(return-deferred state value)
source

run-state-machine-wrappedclj

(run-state-machine-wrapped state)
source

take!clj

(take! state blk d)
source

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close