You are looking at historical revision 17059 of this page. It may differ significantly from its current revision.

termite

Erlang style concurrency for chicken scheme

Documentation

Fundamental Operations

spawn

[procedure] (spawn FUN)

Create a process running fun and returns its pid.

!

[procedure] (! PID MSG)

Send msg to process pid.

?

[procedure] (? [TIMEOUT [DEFAULT]])

Fetch a message from the mailbox.

??

[procedure] (?? PRED)

Fetches next message that matches pred.

!?

[procedure] (!? PID MSG [TIMEOUT [DEFAULT]])

Send msg to process pid and wait for a reply.

[procedure] (spawn-link FUN)

Create a process running fun and returns its pid and link to it. When either process dies, and exception is raised in the other process.

recv

[procedure] (recv ((PAT VAR ACTION) [...]) [(after TIMEOUT TMO-ACTION)])

Receive a message, when it matches pat put it in var and take action (there can be many of these). Optionally, do tmo-action after timeout.

Distributed Operations

make-node

[procedure] (make-node HOST PORT)

Creates a node object for host:port and returns the node object.

node-init

[procedure] (node-init NODE)

Primary setup for creating a node to accept processes.

remote-spawn

[procedure] (remote-spawn NODE FUN)

Run fun on node, returns pid. Node needs to have done a node-init.

[procedure] (remote-spawn-link NODE FUN)

Run fun on node and link to it, returns pid.

Error Handling

with-exception-catcher

[procedure] (with-exception-catcher HANDLER BODY)

Installs a dynamically scoped exception handler handler for the duration of body. Resumes execution a the point where the handler was installed.

with-exception-handler

[procedure] (with-exception-handler HANDLER BODY)

Installs a dynamically scoped exception handler handler for the duration of body. Resumes execution a the point where the exception was raised.

raise

[procedure] (raise EXCEPTION)

Raises exception.

catch

[procedure] (catch HANDLER BODY)

Catches an exception with handler during execution of body.

Examples

Notes

There's a paper about Termite.

Requirements

s11n mailbox mailbox-threads defstruct

Bugs and Limitations

Author

Gulliaume Germain, ported to chicken by Christian Kellermann

Version History

License

Copyright (c) 2005-2008, Guillaume Germain<br> Termite is licensed under the same terms as Gambit-C (LGPL and Apache v.2)<br> It comes with absolutely no warranty of any kind.<br> LGPL 2.1