Home

Awesome

This is a simple and easy to use Actor system in Common Lisp.

Set-Up

Requires Bordeaux threads. http://common-lisp.net/project/bordeaux-threads/ 2. Just load actors.lisp and start using it. If you have Quicklisp, (ql:quickload "cl-actors")

Usage

A small manual can be found at : http://www.cs.rpi.edu/~govinn/actors.pdf

Features

  1. Concurrency using the actors model.
  2. Dynamic behavior change of actors.

Examples

;create the ticker template
(defactor ticker ((counter 0)) (m) 
	     (sleep 2) (pr counter)
	        (incf counter) (send self nil) next)
; Create an instance
(setf t1 (ticker))
; send a message (async)
(send t1 nil)
; to stop use
(stop-actor t1)
	;create the actor template
(defactor print-actor () (val) (pr val) next)
; initialize a new instance
(setf printer (print-actor))
;send values for printing
(send printer "hello, world")
;create the template
(defactor fact ((temp 1)) (n cust) 
	     (if (equal 1 n) 
	            (progn (send cust (* temp 1))
                      (setf temp 1) next)
		             (progn (setf temp (* n temp))
                      (send self (- n 1) cust) next)))
;create a new instance 
(setf f (fact))
; send a value
(send f 4 print-actor)
(defactor nagger () () 
    (sleep 10)
       (trivial-shell:shell-command "say please work")
          (send self) next)
; anonymous actor , no way to stop the nagging 
(send (nagger))

More Resources

  1. Meta-Circular Adventures in Functional Abstraction The wonderful and detailed original blog post is no longer availabe. The link below points to a snaphost. https://hackerfall.com/story/challenging-clojure-in-common-lisp