Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the cl-async-await Reference Manual, version 1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 03:28:25 2022 GMT+0.
Next: Systems, Previous: The cl-async-await Reference Manual, Up: The cl-async-await Reference Manual [Contents][Index]
This library allows you to have async functions similar to those in JavaScript, only these async functions are implemented with threads instead of an event dispatching mechanism.
Cross-thread error handling is easy using CL-ASYNC-AWAIT
, since
the AWAIT
operator propagates errors from the promise, and also
propagates invoked restarts back to the promise.
(defun-async my-async-reader (stream)
(read-byte stream))
(defvar *promise* (my-async-reader *some-stream*))
(defvar *my-byte* (await *promise*))
(lambda-async lambda-list &body body)
Creates a CL:LAMBDA
function that creates a PROMISE
when FUNCALLed.
(defun-async name lambda-list &body body)
Like LAMBDA-ASYNC
but expands to a CL:DEFUN
form instead of a CL:LAMBDA
form.
(await promise)
Wait for a PROMISE
to resolve to one or more values. If the promise
succeeds, the values will be returned using CL:VALUES
.
If an error occurs in the PROMISE
thread and is not handled within the
promise, execution of the PROMISE
thread is suspended until the AWAIT
method is called.
That error will then be signalled in the thread from which AWAIT
is called, in
a context where all the same restarts are defined as are defined in the PROMISE
thread. If INVOKE-RESTART
is called with one of these restarts, that restart
will be invoked in the PROMISE
thread, and AWAIT
will return that restart's value form.
If the stack frame for the call to AWAIT
is unwound without invoking a restart,
the PROMISE
thread will invoke its CL:ABORT
restart.
Whether the PROMISE
succeeds or fails, the result is memoized. Calling AWAIT
a second time
on the same PROMISE
will yield the same values.
If an error occurred and AWAIT
is called a second time, the same error will be signalled, but
the restarts will not be available, since the PROMISE
thread is expected to be dead as a result
of invoking the ABORT
restart.
Next: Files, Previous: Introduction, Up: The cl-async-await Reference Manual [Contents][Index]
The main system appears first, followed by any subsystem dependency.
An implementation of async/await for Common Lisp
Jeremy Phelps
AGPLv3
1
Next: Packages, Previous: Systems, Up: The cl-async-await Reference Manual [Contents][Index]
Files are sorted by type and then listed depth-first from the systems components trees.
Next: cl-async-await/package.lisp, Previous: Lisp, Up: Lisp [Contents][Index]
cl-async-await (system).
Next: cl-async-await/utils.lisp, Previous: cl-async-await/cl-async-await.asd, Up: Lisp [Contents][Index]
cl-async-await (system).
Next: cl-async-await/promise.lisp, Previous: cl-async-await/package.lisp, Up: Lisp [Contents][Index]
package.lisp (file).
cl-async-await (system).
Previous: cl-async-await/utils.lisp, Up: Lisp [Contents][Index]
cl-async-await (system).
Next: Definitions, Previous: Files, Up: The cl-async-await Reference Manual [Contents][Index]
Packages are listed by definition order.
Next: Indexes, Previous: Packages, Up: The cl-async-await Reference Manual [Contents][Index]
Definitions are sorted by export status, category, package, and then by lexicographic order.
Next: Internals, Previous: Definitions, Up: Definitions [Contents][Index]
Next: Generic functions, Previous: Public Interface, Up: Public Interface [Contents][Index]
Like LAMBDA-ASYNC but expands to a CL:DEFUN form instead of CL:LAMBDA.
Creates a closure that creates a PROMISE when FUNCALLed. The BODY
will run in its own thread.
See also: AWAIT
Next: Standalone methods, Previous: Macros, Up: Public Interface [Contents][Index]
Wait for a PROMISE to resolve to one or more values. If the promise
succeeds, the values will be returned using CL:VALUES.
If an error occurs in the PROMISE thread, that error will be signalled in the thread
from which AWAIT is called, in a context where all the same restarts are defined
as are defined in the PROMISE thread. If INVOKE-RESTART is called with one of the
restarts defined in the PROMISE thread, that restart will be invoked in the PROMISE
thread, and AWAIT will return that restart’s value form.
If the stack frame for the call to AWAIT is unwound without invoking a restart,
the PROMISE thread will invoke its CL:ABORT restart.
Whether the PROMISE succeeds or fails, the result is memoized. Calling AWAIT a second time
on the same PROMISE will yield the same values.
If an error occurred and AWAIT is called a second time, the restarts will not be available, since the PROMISE thread is expected to be dead as a result of invoking the ABORT restart.
Next: Classes, Previous: Generic functions, Up: Public Interface [Contents][Index]
Previous: Standalone methods, Up: Public Interface [Contents][Index]
The final values that the promise generated. Only valid if the RESOLVEDP slot is non-nil.
list
:resolution
bordeaux-threads:lock
(bordeaux-threads:make-lock "promise-mutex")
common-lisp.
(or condition null)
:error
bordeaux-threads.
(or bordeaux-threads:thread null)
:thread
simple-actors/ipc::simple-process-mailbox
(simple-actors/ipc:make-mailbox)
This slot is read-only.
simple-actors/ipc::simple-process-mailbox
(simple-actors/ipc:make-mailbox)
This slot is read-only.
function
:thunk
This slot is read-only.
Previous: Public Interface, Up: Definitions [Contents][Index]
Next: Ordinary functions, Previous: Internals, Up: Internals [Contents][Index]
Next: Generic functions, Previous: Macros, Up: Internals [Contents][Index]
Return the cons in ALIST whose car is equal (by a given test or EQL) to the ITEM.
assoc.
Previous: Ordinary functions, Up: Internals [Contents][Index]
Previous: Definitions, Up: The cl-async-await Reference Manual [Contents][Index]
Jump to: | (
A D F G I L M P R |
---|
Jump to: | (
A D F G I L M P R |
---|
Next: Data types, Previous: Functions, Up: Indexes [Contents][Index]
Jump to: | E I M O R S T |
---|
Jump to: | E I M O R S T |
---|
Jump to: | C F P S U |
---|
Jump to: | C F P S U |
---|