This is the clj-con Reference Manual, version 1.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Dec 15 05:40:44 2024 GMT+0.
The main system appears first, followed by any subsystem dependency.
clj-con
Clojure-style concurrency operations like ‘future‘, ‘promise‘, and ‘atom‘.
Dave Tenny
(GIT https://github.com/dtenny/clj-con)
MIT
1.0.0
bordeaux-threads
(system).
atomics
(system).
package.lisp
(file).
clj-con.lisp
(file).
atom.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
clj-con/clj-con.lisp
package.lisp
(file).
clj-con
(system).
deliver
(function).
deref
(generic function).
future
(macro).
future
(structure).
future-call
(function).
future-cancel
(function).
future-cancelled?
(function).
future-done?
(function).
future?
(function).
print-object
(method).
print-object
(method).
promise
(function).
promise
(structure).
realized?
(generic function).
cancellation-exception
(condition).
copy-future
(function).
copy-promise
(function).
execution-exception
(condition).
future-lock
(reader).
(setf future-lock)
(writer).
future-promise
(reader).
(setf future-promise)
(writer).
future-status
(reader).
(setf future-status)
(writer).
future-thread
(reader).
(setf future-thread)
(writer).
make-future
(function).
make-promise
(function).
promise-condition-variable
(reader).
(setf promise-condition-variable)
(writer).
promise-lock
(reader).
(setf promise-lock)
(writer).
promise-p
(function).
promise-realized?
(function).
promise-value
(reader).
(setf promise-value)
(writer).
thread-interrupted
(condition).
with-future-lock
(macro).
clj-con/atom.lisp
clj-con.lisp
(file).
clj-con
(system).
atom
(function).
atom
(structure).
atom?
(function).
compare-and-set!
(function).
deref
(method).
reset!
(function).
reset-vals!
(function).
swap!
(function).
swap-vals!
(function).
atom-cas-vector
(reader).
(setf atom-cas-vector)
(writer).
copy-atom
(function).
make-atom
(function).
Packages are listed by definition order.
clj-con
Functions and macros that implement concurrency operations styled after Clojure operators such as ‘future‘ and ‘promise‘. Note that timeouts in this module are also similar to those found in Clojure and/or the JVM and are expressed as millisecond values, even though Common Lisp normally specifies timeouts as seconds (or fractions thereof).
common-lisp
.
atom
(function).
atom
(structure).
atom?
(function).
compare-and-set!
(function).
deliver
(function).
deref
(generic function).
future
(macro).
future
(structure).
future-call
(function).
future-cancel
(function).
future-cancelled?
(function).
future-done?
(function).
future?
(function).
promise
(function).
promise
(structure).
realized?
(generic function).
reset!
(function).
reset-vals!
(function).
swap!
(function).
swap-vals!
(function).
atom-cas-vector
(reader).
(setf atom-cas-vector)
(writer).
cancellation-exception
(condition).
copy-atom
(function).
copy-future
(function).
copy-promise
(function).
execution-exception
(condition).
future-lock
(reader).
(setf future-lock)
(writer).
future-promise
(reader).
(setf future-promise)
(writer).
future-status
(reader).
(setf future-status)
(writer).
future-thread
(reader).
(setf future-thread)
(writer).
make-atom
(function).
make-future
(function).
make-promise
(function).
promise-condition-variable
(reader).
(setf promise-condition-variable)
(writer).
promise-lock
(reader).
(setf promise-lock)
(writer).
promise-p
(function).
promise-realized?
(function).
promise-value
(reader).
(setf promise-value)
(writer).
thread-interrupted
(condition).
with-future-lock
(macro).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Takes a body of expressions and yields a future object that will
invoke the body in another thread, and will cache the result and
return it on all subsequent calls to deref. If the computation has
not yet finished, calls to deref will block, unless the variant of
deref with timeout is used. See also - realized?.
Note that multiple-value returns are lost, only the first (assumed) value is returned.
Creates and returns an Atom with an initial value of x.
Does not support validator and metadata arguments of the Clojure equivalent.
Atomically sets the value of atom to newval if and only if the current value of the atom is identical (EQ) to oldval. Returns non-NIL if the set happened, NIL if it did not.
Delivers the supplied value to the promise, allowing the return of any blocked derefs.
A subsequent call to deliver on a promise will have no effect.
The first deliver call will return the promise.
Subsequent calls to deliver return NIL.
This is compatible with Clojure, though note that
‘(deliver p 123) (deliver p true)‘ in clojure causes a ClassCastException,
whereas here the second call returns false.
Takes a function of no args and yields a future object that will invoke the function in another thread, and will cache the result and return it on all subsequent calls to deref. If the computation has not yet finished, calls to deref will block, unless the variant of deref with timeout is used. See also - realized?.
Cancels the future, if possible.
Returns T if the cancellation request is successful, NIL if it is not.
Note that interrupting threads in CL is not as tidy as clojure See SB-THREAD::INTERRUPT-THREAD.
Unless threads are carefully using sb-sys:without-interrupts,
their unwind handlers may not work right. Don’t expect something as robust as the JVM’s
InterruptedException.
Return T if the future was explicitly (and successfully) cancelled, NIL otherwise.
Return T if future is done, NIL otherwise.
It is ’done’ if it is in any state other than :ready
(thus hasn’t started, or is executing the supplied forms).
Returns a promise object that can be read with ‘deref‘ and set, once only, with ‘deliver‘. Calls to deref prior to delivery will block unless the variant of deref with timeout is used. All subsequent derefs will return the same delivered value without blocking. See also - ‘realized?‘.
Sets the value of atom to newval without regard for the current value. Returns newval.
Sets the value of atom to newval.
Returns the value of the atom before and after the reset as multiple values.
(Note difference from Clojure which does not have multiple value returns).
Atomically swaps the value of atom to be:
(apply f current-value-of-atom args). Note that f may be called
multiple times, and thus should be free of side effects. Returns
the value that was swapped in.
Atomically swaps the value of atom to be:
(apply f current-value-of-atom args). Note that f may be called
multiple times, and thus should be free of side effects. Returns un-Clojure-y
multiple values ‘(old new)‘, the value of the atom before and after the swap.
Used on various objects to obtain a value from an asynchronous construct.
When applied to an atom, yields the current value of the atom.
When applied to a future, will block if computation not complete.
If the future completed unsuccessfully, deref will signal either cancellation-exception
or execution-exception depending on whether it was cancelled or unwound due to unhandled conditions.
When applied to a promise, will block until a value is delivered.
When called with timeout options (valid only for promises and futures),
can be used for blocking and will return
timeout-val if the timeout (in milliseconds) is reached before a
value is available. See also - realized?.
Note that a call to ‘deref‘ with a timeout the returns the timeout value
does not force the promise/future to be ‘realized?‘, it may remain unrealized.
Note that if timeout-ms is supplied, timeout-val is also required, to maintain
parity with Clojure’s arity-1 and arity-3 (but no arity-2) calls.
Returns true if a value has been produced for a promise or future, nil otherwise.
structure-object
.
(array t 1)
#(nil)
A future object returned by the ‘future‘ macro.
A promise object as created by the ‘promise‘ function.
Execute body with the future locked.
lock
.
lock
.
True if value has been supplied, caller must lock before calling.
Signalled by deref (in the calling thread) when a a ‘future‘ thread was cancelled. Named for similarity to clojure/java behavior on deref.
error
.
Signalled by deref (in the calling thread) when a ‘future‘ thread unwound its stack with an unhandled signal. Named for similarity to clojure/java behavior on deref.
error
.
The thread-interrupted condition is signalled in ‘future‘ threads when ‘future-cancel‘ is called.
condition
.
Jump to: | (
A C D F G M P R S W |
---|
Jump to: | (
A C D F G M P R S W |
---|
Jump to: | C L P S T V |
---|
Jump to: | C L P S T V |
---|
Jump to: | A C E F P S T |
---|
Jump to: | A C E F P S T |
---|