The cl-actors Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The cl-actors Reference Manual

This is the cl-actors Reference Manual, version 1.0, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 11:37:55 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

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

An 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)


- A print actor: Prints the message which was sent to it. A very useful utility actor. 

  ```lisp
	;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)


- A nagger for fun : Works only in Mac OS X. Keeps saying out aloud "please work" every 10 seconds :)

   ```lisp
(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 –Challenging Clojure in Common Lisp] (http://chriskohlhepp.wordpress.com/metacircular-adventures-in-functional-abstraction-challenging-clojure-in-common-lisp/

Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 cl-actors

Author

Naveen Sundar G. <naveensundarg@gmail.com>

License

BSD

Description

A simple common lisp actors library.

Version

1.0

Dependency

bordeaux-threads

Source

cl-actors.asd (file)

Components

Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 cl-actors.asd

Location

cl-actors.asd

Systems

cl-actors (system)

Packages

cl-actors-asd


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 cl-actors/package.lisp

Parent

cl-actors (system)

Location

package.lisp

Packages

cl-actors


Previous: , Up: Lisp files   [Contents][Index]

3.1.3 cl-actors/actors.lisp

Dependency

package.lisp (file)

Parent

cl-actors (system)

Location

actors.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

4.1 cl-actors-asd

Source

cl-actors.asd

Use List

Previous: , Up: Packages   [Contents][Index]

4.2 cl-actors

Source

package.lisp (file)

Use List
Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Macros

Macro: behav STATE VARS &body BODY
Package

cl-actors

Source

actors.lisp (file)

Macro: defactor NAME STATE VARS &body BODY
Package

cl-actors

Source

actors.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Functions

Function: printer &key SELF
Package

cl-actors

Source

actors.lisp (file)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Generic functions

Generic Function: send SELF &rest MESSAGE
Package

cl-actors

Methods
Method: send (SELF actor) &rest MESSAGE

Creates a message sending thread which
1. Holds lock to the message (queue)
2. Appends messages (queue) with incoming message 3. Releases lock
4. Notifies the waiting thread that there is a message

Source

actors.lisp (file)

Generic Function: stop-actor SELF
Package

cl-actors

Methods
Method: stop-actor (SELF actor)

Stops the actor thread

Source

actors.lisp (file)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Functions

Function: curry F &rest ARGS
Package

cl-actors

Source

actors.lisp (file)

Function: if-single X
Package

cl-actors

Source

actors.lisp (file)

Function: make-actor BEHAV NAME
Package

cl-actors

Source

actors.lisp (file)

Function: pr X
Package

cl-actors

Source

actors.lisp (file)

Function: sink &rest ARGS
Package

cl-actors

Source

actors.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Generic functions

Generic Function: behavior OBJECT
Generic Function: (setf behavior) NEW-VALUE OBJECT
Package

cl-actors

Methods
Method: behavior (ACTOR actor)
Method: (setf behavior) NEW-VALUE (ACTOR actor)

Behavior

Source

actors.lisp (file)

Generic Function: cv OBJECT
Generic Function: (setf cv) NEW-VALUE OBJECT
Package

cl-actors

Methods
Method: cv (ACTOR actor)
Method: (setf cv) NEW-VALUE (ACTOR actor)

conditional variable used by the thread

Source

actors.lisp (file)

Generic Function: get-thread SELF
Package

cl-actors

Methods
Method: get-thread (SELF actor)

Returns the handle of a thread

Source

actors.lisp (file)

Generic Function: lock OBJECT
Generic Function: (setf lock) NEW-VALUE OBJECT
Package

cl-actors

Methods
Method: lock (ACTOR actor)
Method: (setf lock) NEW-VALUE (ACTOR actor)

The lock is used when adding a message to the message queue

Source

actors.lisp (file)

Generic Function: main SELF
Package

cl-actors

Methods
Method: main (SELF actor)
Source

actors.lisp (file)

Generic Function: messages OBJECT
Generic Function: (setf messages) NEW-VALUE OBJECT
Package

cl-actors

Methods
Method: messages (ACTOR actor)
Method: (setf messages) NEW-VALUE (ACTOR actor)

Message stream sent to actor

Source

actors.lisp (file)

Generic Function: name OBJECT
Generic Function: (setf name) NEW-VALUE OBJECT
Package

cl-actors

Methods
Method: name (ACTOR actor)
Method: (setf name) NEW-VALUE (ACTOR actor)

Hold the name of actor

Source

actors.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.3 Classes

Class: actor ()
Package

cl-actors

Source

actors.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: name

Hold the name of actor

Initargs

:name

Initform

(error ":name must be specified")

Readers

name (generic function)

Writers

(setf name) (generic function)

Slot: behavior

Behavior

Initargs

:behavior

Initform

(error ":behav must be specified")

Readers

behavior (generic function)

Writers

(setf behavior) (generic function)

Slot: messages

Message stream sent to actor

Initform

(quote nil)

Readers

messages (generic function)

Writers

(setf messages) (generic function)

Slot: lock

The lock is used when adding a message to the message queue

Initform

(bordeaux-threads:make-lock)

Readers

lock (generic function)

Writers

(setf lock) (generic function)

Slot: cv

conditional variable used by the thread

Initargs

:cv

Initform

(bordeaux-threads:make-condition-variable)

Readers

cv (generic function)

Writers

(setf cv) (generic function)

Slot: thread

Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   C   F   L  
Index Entry  Section

C
cl-actors.asd: The cl-actors<dot>asd file
cl-actors/actors.lisp: The cl-actors/actors<dot>lisp file
cl-actors/package.lisp: The cl-actors/package<dot>lisp file

F
File, Lisp, cl-actors.asd: The cl-actors<dot>asd file
File, Lisp, cl-actors/actors.lisp: The cl-actors/actors<dot>lisp file
File, Lisp, cl-actors/package.lisp: The cl-actors/package<dot>lisp file

L
Lisp File, cl-actors.asd: The cl-actors<dot>asd file
Lisp File, cl-actors/actors.lisp: The cl-actors/actors<dot>lisp file
Lisp File, cl-actors/package.lisp: The cl-actors/package<dot>lisp file

Jump to:   C   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   (  
B   C   D   F   G   I   L   M   N   P   S  
Index Entry  Section

(
(setf behavior): Internal generic functions
(setf behavior): Internal generic functions
(setf cv): Internal generic functions
(setf cv): Internal generic functions
(setf lock): Internal generic functions
(setf lock): Internal generic functions
(setf messages): Internal generic functions
(setf messages): Internal generic functions
(setf name): Internal generic functions
(setf name): Internal generic functions

B
behav: Exported macros
behavior: Internal generic functions
behavior: Internal generic functions

C
curry: Internal functions
cv: Internal generic functions
cv: Internal generic functions

D
defactor: Exported macros

F
Function, curry: Internal functions
Function, if-single: Internal functions
Function, make-actor: Internal functions
Function, pr: Internal functions
Function, printer: Exported functions
Function, sink: Internal functions

G
Generic Function, (setf behavior): Internal generic functions
Generic Function, (setf cv): Internal generic functions
Generic Function, (setf lock): Internal generic functions
Generic Function, (setf messages): Internal generic functions
Generic Function, (setf name): Internal generic functions
Generic Function, behavior: Internal generic functions
Generic Function, cv: Internal generic functions
Generic Function, get-thread: Internal generic functions
Generic Function, lock: Internal generic functions
Generic Function, main: Internal generic functions
Generic Function, messages: Internal generic functions
Generic Function, name: Internal generic functions
Generic Function, send: Exported generic functions
Generic Function, stop-actor: Exported generic functions
get-thread: Internal generic functions
get-thread: Internal generic functions

I
if-single: Internal functions

L
lock: Internal generic functions
lock: Internal generic functions

M
Macro, behav: Exported macros
Macro, defactor: Exported macros
main: Internal generic functions
main: Internal generic functions
make-actor: Internal functions
messages: Internal generic functions
messages: Internal generic functions
Method, (setf behavior): Internal generic functions
Method, (setf cv): Internal generic functions
Method, (setf lock): Internal generic functions
Method, (setf messages): Internal generic functions
Method, (setf name): Internal generic functions
Method, behavior: Internal generic functions
Method, cv: Internal generic functions
Method, get-thread: Internal generic functions
Method, lock: Internal generic functions
Method, main: Internal generic functions
Method, messages: Internal generic functions
Method, name: Internal generic functions
Method, send: Exported generic functions
Method, stop-actor: Exported generic functions

N
name: Internal generic functions
name: Internal generic functions

P
pr: Internal functions
printer: Exported functions

S
send: Exported generic functions
send: Exported generic functions
sink: Internal functions
stop-actor: Exported generic functions
stop-actor: Exported generic functions

Jump to:   (  
B   C   D   F   G   I   L   M   N   P   S  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   B   C   L   M   N   S   T  
Index Entry  Section

B
behavior: Internal classes

C
cv: Internal classes

L
lock: Internal classes

M
messages: Internal classes

N
name: Internal classes

S
Slot, behavior: Internal classes
Slot, cv: Internal classes
Slot, lock: Internal classes
Slot, messages: Internal classes
Slot, name: Internal classes
Slot, thread: Internal classes

T
thread: Internal classes

Jump to:   B   C   L   M   N   S   T  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   A   C   P   S  
Index Entry  Section

A
actor: Internal classes

C
cl-actors: The cl-actors system
cl-actors: The cl-actors package
cl-actors-asd: The cl-actors-asd package
Class, actor: Internal classes

P
Package, cl-actors: The cl-actors package
Package, cl-actors-asd: The cl-actors-asd package

S
System, cl-actors: The cl-actors system

Jump to:   A   C   P   S