Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/termite|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. == termite Erlang style concurrency for Chicken Scheme [[toc:]] == Documentation === Fundamental Operations ==== spawn <procedure>(spawn THUNK)</procedure> Create a process running {{thunk}} and returns its {{pid}}. ==== ! <procedure>(! PID MSG)</procedure> Send {{msg}} to process {{pid}}. ==== ? <procedure>(? [TIMEOUT [DEFAULT]])</procedure> Fetch a message from the mailbox. {{timeout}} is in seconds. ==== ?? <procedure>(?? PRED)</procedure> Fetches next message that matches {{pred}}. ==== !? <procedure>(!? PID MSG [TIMEOUT [DEFAULT]])</procedure> Send {{msg}} to process {{pid}} and wait for a reply. ==== recv <procedure>(recv ((PAT VAR ACTION) [...]) [(after TIMEOUT TMO-ACTION)])</procedure> 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}}. (This was documented from the termite.pdf, but it's not exported in chicken's termite.) ==== spawn-link <procedure>(spawn-link THUNK)</procedure> Create a process running {{thunk}} and returns its {{pid}} and link to it. When either process dies, and exception is raised in the other process. ==== spawn-linked-to <procedure>(spawn-linked-to THUNK TO)</procedure> Create a process running {{thunk}} and returns its {{pid}} and have it link to {{to}} (a pid). When either process dies, and exception is raised in the other process. === Distributed Operations ==== make-node <procedure>(make-node HOST PORT)</procedure> Creates a node object for {{host:port}} and returns the node object. ==== node-init <procedure>(node-init NODE)</procedure> Primary setup for creating a {{node}} to accept processes. ==== remote-spawn <procedure>(remote-spawn NODE THUNK)</procedure> Run {{thunk}} on {{node}}, returns {{pid}}. Node needs to have done a {{node-init}}. ==== remote-spawn-link <procedure>(remote-spawn-link NODE THUNK)</procedure> Run {{thunk}} on {{node}} and link to it, returns {{pid}}. ==== on <procedure>(on NODE THUNK)</procedure> Run {{thunk}} on {{node}}, returns result of {{thunk}}. === Error Handling ==== with-exception-catcher <procedure>(with-exception-catcher HANDLER BODY)</procedure> 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)</procedure> 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)</procedure> Raises {{exception}}. ==== catch <procedure>(catch HANDLER BODY)</procedure> Catches an exception with {{handler}} during execution of {{body}}. === Stopping ==== shutdown! <procedure>(shutdown!)</procedure> Stops gracefully. Linked processes receive a "normal" exit message. ==== halt! <procedure>(halt!)</procedure> Stops ungracefully. Linked processes are clueless as to what happened. ==== terminate! <procedure>(terminate! VICTIM)</procedure> Forcefully terminate a local(!) process. Processed linked to {{victim}} get a {{terminated}} message. == Examples === Making a "server" process (define pong-server (spawn (lambda () (let loop () (let ((msg (?))) (if (and (list? msg) (= (length msg) 2) (pid? (car msg)) (eq? (cadr msg) 'ping)) (let ((from (car msg))) (! from 'pong) (loop)) (loop))))))) (! pong-server (list (self) 'ping)) (?) --> pong === Selective message retrieval (! (self) 1) (! (self) 2) (! (self) 3) (?) --> 1 (?? odd?) --> 3 (?) --> 2 === Distributed processing On node a: (node-init (make-node "a.example.org" 12345)) On node b: (define node-a (make-node "a.example.org" 12345)) (on node-a host-name) --> "a.example.org" (define p (remote-spawn node-a (lambda () (let loop () (let ((x (?))) (! (car x) ((cdr x))) (loop)))))) (! p (cons (self) host-name)) (?) --> "a.example.org" == Notes There's a [[http://termite.googlecode.com/files/termite.pdf|paper]] about Termite. == Requirements [[/eggref/4/s11n|s11n]] [[/eggref/4/mailbox|mailbox]] mailbox-threads [[/eggref/4/defstruct|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
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 4 to 14?