The simple-actors Reference Manual

This is the simple-actors Reference Manual, version 1, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 17:53:09 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

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


2.1 simple-actors

Actor model implemented with closures.

Author

Jeremy Phelps

License

BSD

Version

1

Dependency

bordeaux-threads (system).

Source

simple-actors.asd.

Child Components

3 Files

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


3.1 Lisp


3.1.1 simple-actors/simple-actors.asd

Source

simple-actors.asd.

Parent Component

simple-actors (system).

ASDF Systems

simple-actors.


3.1.2 simple-actors/actors.lisp

Dependencies
Source

simple-actors.asd.

Parent Component

simple-actors (system).

Packages

simple-actors.

Public Interface
Internals

3.1.4 simple-actors/better-handler-case.lisp

Source

simple-actors.asd.

Parent Component

simple-actors (system).

Packages

simple-actors/better-handler-case.

Public Interface

handler-case* (macro).

Internals

4 Packages

Packages are listed by definition order.


4.1 simple-actors/ipc

This package provides a basic method for threads to send messages to each other.

Source

ipc.lisp.

Use List
  • bordeaux-threads.
  • common-lisp.
Used By List

simple-actors.

Public Interface
Internals

4.2 simple-actors

Source

actors.lisp.

Use List
Public Interface
Internals

4.3 simple-actors/better-handler-case

Source

better-handler-case.lisp.

Nickname

handler-case*

Use List

common-lisp.

Used By List

simple-actors.

Public Interface

handler-case* (macro).

Internals

5 Definitions

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


5.1 Public Interface


5.1.1 Special variables

Special Variable: *current-channel*
Package

simple-actors.

Source

actors.lisp.


5.1.2 Macros

Macro: actor (lambda-list &rest body)

Similar to LAMBDA, except the object created is an ACTOR instead of a FUNCTION. The ACTOR will wait
for messages and evaluate the BODY sequentially each time a message is received.

You can send messages to the actor with SEND. The &REST arguments to SEND must match the actor’s lambda-list
with one exception: A message consisting of the single argument ’SIMPLE-ACTORS:STOP will terminate the actor’s thread immediately without attempting to bind the actor’s arguments or evaluate its BODY. However, the ’ACTORS:STOP message cannot interrupt the BODY if it is being evaluated when the message is sent. ’SIMPLE-ACTORS:STOP is processed when the actor begins waiting for a new message.

Within BODY, the variable SIMPLE-ACTORS:SELF is lexically bound to
the current actor.

The first form of the BODY is expected to be a plist. The :CLASS property of this plist can be used
to specify a class other than SIMPLE-ACTORS:ACTOR to use for the actor object. If the first form of the BODY doesn’t look like a plist with property names specified by keywords, for backwards compatibility it will be
assumed to be an ordinary form, and will be included in the body of the message-handling function.

Package

simple-actors.

Source

actors.lisp.

Macro: defactor (name lambda-list &body body)

Like DEFUN but for actors. The resulting NAME is a variable whose value is an actor.

Package

simple-actors.

Source

actors.lisp.

Macro: handler-case* (form &rest cases)

Like HANDLER-CASE and HANDLER-BIND rolled into one. Example usage:

(handler-case* (restart-case (error "ZOMG! ERROR!")
(fuck-it () ’ignored))
(t (condition)
:before-unwind
(progn (format t "An error occurred Ignore it (y/N)? ")
(if (eq (read) ’y)
(invoke-restart ’fuck-it)))
:after-unwind
(format t "You just couldn’t fucking ignore it, could you?~%")))

:before-unwind is, of course, executed before the stack unrolls, so you can
invoke restarts from there. If no restart is invoked, the error falls through
to the :after-unwind case, where you can handle it like a regular handler-case.

If no :after-unwind form is provided and no restart is invoked, the condition is not trapped.

Package

simple-actors/better-handler-case.

Source

better-handler-case.lisp.

Macro: server (var &rest body)

Spawns a thread that you can interact with through a TWO-WAY-CHANNEL.
In the new thread, that channel will be bound to the VAR (and also to SIMPLE-ACTORS:*CURRENT-CHANNEL*) and then the BODY will be evaluated. The thread terminates when the BODY completes.

The SERVER form returns two values: The two-way-channel through which you may communicate
interactively with the server, and the thread object.

Package

simple-actors.

Source

actors.lisp.


5.1.3 Ordinary functions

Function: channel-receive (channel &key timeout role error-if-empty default-value non-blocking)
Package

simple-actors.

Source

actors.lisp.

Function: channel-send (channel message &key role)

Sends a message through a two-way-channel. The actors on either end of a two-way-channel play two roles on this channel: Either :CLIENT or :SERVER.

Package

simple-actors.

Source

actors.lisp.

Function: get-message (mailbox &key error-if-empty default-value non-blocking timeout)

Reads a message from the given MAILBOX object. By default, if there are no messages,
GET-MESSAGE will block until a message arrives in the MAILBOX.

Keys:

:NON-BLOCKING If set to T, then GET-MESSAGE will return immediately even if there are no messages. :DEFAULT-VALUE In non-blocking mode, this is the default return value if there are no messages. :ERROR-IF-EMPTY If set to T :NON-BLOCKING is also T, and there are no messages, a condition of type ’MAILBOX-IS-EMPTY will be signalled.

See also: SEND-MESSAGE, MAILBOX

Package

simple-actors/ipc.

Source

ipc.lisp.

Function: make-mailbox ()
Package

simple-actors/ipc.

Source

ipc.lisp.

Function: send-message (mailbox message)

Sends a MESSAGE to the specified MAILBOX. The MESSAGE can be any Lisp value. If the mailbox does not exist, it will be created.

See also: GET-MESSAGE

Package

simple-actors/ipc.

Source

ipc.lisp.


5.1.4 Generic functions

Generic Function: send (actor &rest message)
Package

simple-actors.

Source

actors.lisp.

Methods
Method: send ((actor actor) &rest message)

5.1.5 Classes

Class: actor
Package

simple-actors.

Source

actors.lisp.

Direct methods

send.

Direct slots
Slot: mailbox
Initform

(simple-actors/ipc:make-mailbox)

Initargs

:mailbox

Slot: logic
Type

bordeaux-threads:thread

Initargs

:logic


5.2 Internals


5.2.1 Special variables

Special Variable: *channel-role*
Package

simple-actors.

Source

actors.lisp.

Special Variable: *default-channel-timeout*
Package

simple-actors.

Source

actors.lisp.


5.2.2 Macros

Macro: without-mutex ((mutex) &body body)
Package

simple-actors/ipc.

Source

ipc.lisp.


5.2.3 Ordinary functions

Function: copy-simple-process-mailbox (instance)
Package

simple-actors/ipc.

Source

ipc.lisp.

Function: expand-handler-bind (type lambda-list &key before-unwind after-unwind)

Helper for the HANDLER-CASE* macro. This one creates the HANDLER-BIND lambdas out of the :BEFORE-UNWIND form.

Package

simple-actors/better-handler-case.

Source

better-handler-case.lisp.

Function: expand-handler-case (type lambda-list &key before-unwind after-unwind)

Helper for the HANDLER-CASE* macro. This one creates the HANDLER-CASE handler-clauses out of the :AFTER-UNWIND form

Package

simple-actors/better-handler-case.

Source

better-handler-case.lisp.

Function: looks-like-old-actor-form (body)
Package

simple-actors.

Source

actors.lisp.

Function: make-simple-process-mailbox (&key lock blocker unread-messages read-messages)
Package

simple-actors/ipc.

Source

ipc.lisp.

Function: mapapply (func list)

Maps over a list, treating each element in the list as an argument list for FUNC.

Package

simple-actors/better-handler-case.

Source

better-handler-case.lisp.

Function: server-interaction-repl (channel &key receive-first)
Package

simple-actors.

Source

actors.lisp.

Reader: simple-process-mailbox-blocker (instance)
Writer: (setf simple-process-mailbox-blocker) (instance)
Package

simple-actors/ipc.

Source

ipc.lisp.

Target Slot

blocker.

Reader: simple-process-mailbox-lock (instance)
Writer: (setf simple-process-mailbox-lock) (instance)
Package

simple-actors/ipc.

Source

ipc.lisp.

Target Slot

lock.

Function: simple-process-mailbox-p (object)
Package

simple-actors/ipc.

Source

ipc.lisp.

Reader: simple-process-mailbox-read-messages (instance)
Writer: (setf simple-process-mailbox-read-messages) (instance)
Package

simple-actors/ipc.

Source

ipc.lisp.

Target Slot

read-messages.

Reader: simple-process-mailbox-unread-messages (instance)
Writer: (setf simple-process-mailbox-unread-messages) (instance)
Package

simple-actors/ipc.

Source

ipc.lisp.

Target Slot

unread-messages.


5.2.4 Conditions

Condition: mailbox-is-empty
Package

simple-actors/ipc.

Source

ipc.lisp.

Direct superclasses

condition.

Condition: semaphore-timeout
Package

simple-actors/ipc.

Source

ipc.lisp.

Direct superclasses

simple-error.


5.2.5 Structures

Structure: simple-process-mailbox
Package

simple-actors/ipc.

Source

ipc.lisp.

Direct superclasses

structure-object.

Direct slots
Slot: lock
Package

bordeaux-threads.

Type

bordeaux-threads:lock

Initform

(bordeaux-threads:make-lock)

Readers

simple-process-mailbox-lock.

Writers

(setf simple-process-mailbox-lock).

Slot: blocker
Type

bordeaux-threads:semaphore

Initform

(bordeaux-threads:make-semaphore)

Readers

simple-process-mailbox-blocker.

Writers

(setf simple-process-mailbox-blocker).

Slot: unread-messages
Type

list

Readers

simple-process-mailbox-unread-messages.

Writers

(setf simple-process-mailbox-unread-messages).

Slot: read-messages
Type

list

Readers

simple-process-mailbox-read-messages.

Writers

(setf simple-process-mailbox-read-messages).


5.2.6 Classes

Class: two-way-channel
Package

simple-actors.

Source

actors.lisp.

Direct slots
Slot: inbound
Initform

(simple-actors/ipc:make-mailbox)

Initargs

:inbound

Slot: outbound
Initform

(simple-actors/ipc:make-mailbox)

Initargs

:outbound


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   (  
A   C   D   E   F   G   H   L   M   S   W  
Index Entry  Section

(
(setf simple-process-mailbox-blocker): Private ordinary functions
(setf simple-process-mailbox-lock): Private ordinary functions
(setf simple-process-mailbox-read-messages): Private ordinary functions
(setf simple-process-mailbox-unread-messages): Private ordinary functions

A
actor: Public macros

C
channel-receive: Public ordinary functions
channel-send: Public ordinary functions
copy-simple-process-mailbox: Private ordinary functions

D
defactor: Public macros

E
expand-handler-bind: Private ordinary functions
expand-handler-case: Private ordinary functions

F
Function, (setf simple-process-mailbox-blocker): Private ordinary functions
Function, (setf simple-process-mailbox-lock): Private ordinary functions
Function, (setf simple-process-mailbox-read-messages): Private ordinary functions
Function, (setf simple-process-mailbox-unread-messages): Private ordinary functions
Function, channel-receive: Public ordinary functions
Function, channel-send: Public ordinary functions
Function, copy-simple-process-mailbox: Private ordinary functions
Function, expand-handler-bind: Private ordinary functions
Function, expand-handler-case: Private ordinary functions
Function, get-message: Public ordinary functions
Function, looks-like-old-actor-form: Private ordinary functions
Function, make-mailbox: Public ordinary functions
Function, make-simple-process-mailbox: Private ordinary functions
Function, mapapply: Private ordinary functions
Function, send-message: Public ordinary functions
Function, server-interaction-repl: Private ordinary functions
Function, simple-process-mailbox-blocker: Private ordinary functions
Function, simple-process-mailbox-lock: Private ordinary functions
Function, simple-process-mailbox-p: Private ordinary functions
Function, simple-process-mailbox-read-messages: Private ordinary functions
Function, simple-process-mailbox-unread-messages: Private ordinary functions

G
Generic Function, send: Public generic functions
get-message: Public ordinary functions

H
handler-case*: Public macros

L
looks-like-old-actor-form: Private ordinary functions

M
Macro, actor: Public macros
Macro, defactor: Public macros
Macro, handler-case*: Public macros
Macro, server: Public macros
Macro, without-mutex: Private macros
make-mailbox: Public ordinary functions
make-simple-process-mailbox: Private ordinary functions
mapapply: Private ordinary functions
Method, send: Public generic functions

S
send: Public generic functions
send: Public generic functions
send-message: Public ordinary functions
server: Public macros
server-interaction-repl: Private ordinary functions
simple-process-mailbox-blocker: Private ordinary functions
simple-process-mailbox-lock: Private ordinary functions
simple-process-mailbox-p: Private ordinary functions
simple-process-mailbox-read-messages: Private ordinary functions
simple-process-mailbox-unread-messages: Private ordinary functions

W
without-mutex: Private macros


A.4 Data types

Jump to:   A   B   C   F   I   M   P   S   T  
Index Entry  Section

A
actor: Public classes
actors.lisp: The simple-actors/actors․lisp file

B
better-handler-case.lisp: The simple-actors/better-handler-case․lisp file

C
Class, actor: Public classes
Class, two-way-channel: Private classes
Condition, mailbox-is-empty: Private conditions
Condition, semaphore-timeout: Private conditions

F
File, actors.lisp: The simple-actors/actors․lisp file
File, better-handler-case.lisp: The simple-actors/better-handler-case․lisp file
File, ipc.lisp: The simple-actors/ipc․lisp file
File, simple-actors.asd: The simple-actors/simple-actors․asd file

I
ipc.lisp: The simple-actors/ipc․lisp file

M
mailbox-is-empty: Private conditions

P
Package, simple-actors: The simple-actors package
Package, simple-actors/better-handler-case: The simple-actors/better-handler-case package
Package, simple-actors/ipc: The simple-actors/ipc package

S
semaphore-timeout: Private conditions
simple-actors: The simple-actors system
simple-actors: The simple-actors package
simple-actors.asd: The simple-actors/simple-actors․asd file
simple-actors/better-handler-case: The simple-actors/better-handler-case package
simple-actors/ipc: The simple-actors/ipc package
simple-process-mailbox: Private structures
Structure, simple-process-mailbox: Private structures
System, simple-actors: The simple-actors system

T
two-way-channel: Private classes