Liking cljdoc? Tell your friends :D

is.simm.partial-cps.async


*in-trampoline*clj/s

source

asyncclj/smacro

(async & body)

Defines a function that takes a successful and exceptional continuation, and runs the body, suspending execution whenever any of the breakpoints (await) is encountered, and eventually calling one of the continuations with the result.

A call of the form (breakpoint args..) is forwarded to the corresponding handler (handler succ exc args..), which is expected to eventually call either succ with the value or exc with exception to substitute the original call result and resuming the execution.

Defines a function that takes a successful and exceptional continuation,
and runs the body, suspending execution whenever any of the breakpoints (await) is
encountered, and eventually calling one of the continuations with the
result.

A call of the form (breakpoint args..) is forwarded to the corresponding handler
(handler succ exc args..), which is expected to eventually call either succ
with the value or exc with exception to substitute the original call result
and resuming the execution.
sourceraw docstring

awaitclj/s

(await async-cb)

Awaits the asynchronous execution of continuation-passing style function async-cb, applying it to args and two extra callback functions: resolve and raise. cps-fn is expected to eventually either call resolve with the result, call raise with the exception or just throw in the calling thread. The return value of cps-fn is ignored. Effectively returns the value passed to resolve or throws the exception passed to raise (or thrown) but does not block the calling tread.

Must be called in an asynchronous function. Note that any nested functions defined with fn, letfn, reify or deftype are considered outside of asynchronous scope.

Awaits the asynchronous execution of continuation-passing style function
async-cb, applying it to args and two extra callback functions: resolve and
raise. cps-fn is expected to eventually either call resolve with the result,
call raise with the exception or just throw in the calling thread. The
return value of cps-fn is ignored. Effectively returns the value passed to
resolve or throws the exception passed to raise (or thrown) but does not
block the calling tread.

Must be called in an asynchronous function. Note that any nested functions
defined with fn, letfn, reify or deftype are considered outside of
asynchronous scope.
sourceraw docstring

await-handlerclj/s

(await-handler ctx r e)

Provides effect handler code for await.

Receives ctx map containing:

  • :env - macro expansion environment (&env)
  • :r - success continuation
  • :e - error continuation
  • :breakpoints - registered breakpoints Plus any additional macro-specific context fields.
Provides effect handler code for await.

Receives ctx map containing:
- :env - macro expansion environment (&env)
- :r - success continuation
- :e - error continuation
- :breakpoints - registered breakpoints
Plus any additional macro-specific context fields.
sourceraw docstring

invoke-continuationclj/s

(invoke-continuation cont-fn & args)

Invoke a CPS continuation, handling Thunk returns via trampoline.

This is the universal continuation invocation wrapper that ensures Thunks are properly trampolined, preventing stack overflow in loops.

Usage: (invoke-continuation resolve-fn value) (invoke-continuation reject-fn error)

If the continuation returns a Thunk, it will be executed via trampoline. This is essential for loop/recur constructs in CPS-transformed code.

Invoke a CPS continuation, handling Thunk returns via trampoline.

This is the universal continuation invocation wrapper that ensures
Thunks are properly trampolined, preventing stack overflow in loops.

Usage:
  (invoke-continuation resolve-fn value)
  (invoke-continuation reject-fn error)

If the continuation returns a Thunk, it will be executed via trampoline.
This is essential for loop/recur constructs in CPS-transformed code.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close