golang-like channels for CL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
Avril 38b01ee387
copy some async stuff from flan-utils
6 years ago
README copy some async stuff from flan-utils 6 years ago
async-tools.lisp copy some async stuff from flan-utils 6 years ago
cl-box.lisp remove unneeded dependancy 6 years ago
cl-channel.asd copy some async stuff from flan-utils 6 years ago
cl-channel.lisp copy some async stuff from flan-utils 6 years ago
cl-dispatcher.lisp copy some async stuff from flan-utils 6 years ago
package.lisp copy some async stuff from flan-utils 6 years ago

README

=== Go-like channels for atomically passing information between threads, and some other stuff. ===

(channel:make-channel) ; make new channel
(channel:make-channel 2) ; make new channel with max size of 2 (untested)

(channel:-> chan item) ; send item to channel
(channel:<- chan) ; receive from channel (values item is-not-closed), blocks until there is one
(channel:release chan) ; close channel
(channel:closed chan) ; is channel closed
(channel:¬closed chan) ; (not (closed chan))

--- Signalling ---

(dispatcher:make-dispatcher) ; make dispatcher

(dispatcher:hook disp name lambda) ; add hook
(dispatcher:sig name (optional value)) ; signal name in parallel
(dispatcher:sig-serial name (optional value)) ; signal name in serial

--- Atomic operations ---

(box:make &optional value) ; make a box with default value

(box:<- box) ; get value atomically
(box:-> box value) ; set value atomically
(box:<-! box) ; get value without lock
(box:->! box vlaue) ; set value without lock
(setf (box:@ box) value) ; set value atomically

(box:--> box &body things) ; do (progn ,@things) with lock held then set value to box
(box:<-- box &body things) ; do (progn ,@things) with lock held. return value of box.
	; these two macros flet functions (box:<-) and (box:-> thing) to get&set from box while lock is held.