cl-coroutine: a coroutine library for Common Lisp

CL-COROUTINE is a coroutine library for Common Lisp. It uses CL-CONT continuations library in its implementation. Here I show an example to use it. For detail, please see the project repository below.

cl-coroutine: a coroutine library for Common Lisp

Example

Here shows an example how to use cl-coroutine.

;; define a coroutine using DEFCOROUTINE macro 
(defcoroutine example (whom) 
  (format t "First greeting to: ~A~%" whom) 
  (yield 1) 
  (format t "Second greeting to: ~A~%" whom) 
  (yield 2) 
  (format t "Third greeting to: ~A~%" whom) 
  (coexit 3) 
  (format t "No greeting to: ~A~%" whom) 
  (yield 4)) 
=> EXAMPLE 

;; make a coroutine object 
(setf coroutine (make-coroutine 'example)) 
=> a coroutine object 

;; funcall it 
(funcall coroutine "Smith") 
>> First greeting to: Smith 
=> 1

I want your feedbacks. Thanks.

Project repository

cl-coroutine: a coroutine library for Common Lisp

Written by Masayuki Takagi