|
Index of /munro/cl-spread
|
Name Last modified Size Description
Parent Directory 16-Jan-2010 19:05 -
cl-spread.asd 09-May-2009 09:15 1k
README.txt 09-May-2009 09:15 3k
cl-spread.lisp 09-May-2009 09:15 14k
Common Lisp bindings for the Spread Toolkit (using CFFI)
=== BEGIN LICENCE (MIT/X11) ===
Copyright (c) 2009 Thomas Munro <munro@ip9.org>
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
=== END LICENCE ===
See http://www.spread.org/ for more about the Spread Toolkit and what
the various function calls mean. Tested with Spread 3.17.4-2+b1
and SBCL 1.0.18.debian.
Examples of use (assuming a local Spread daemon on the default port):
;; A simple program to send 10 messages and disconnect.
(spread:with-mailbox (mailbox)
(dotimes (i 10)
(spread:multicast mailbox :safe "MY_GROUP" 0 (format nil "FOO ~a" i) nil)))
;; A simple program to receive and print up to 5 messages (blocking).
(spread:with-mailbox (mailbox)
(spread:join mailbox "MY_GROUP")
(dotimes (i 5)
(let ((envelope (spread:receive mailbox)))
(if (spread:regular-message? envelope)
(format t "Got message: ~a~%" (spread:envelope-message envelope))
(format t "Got membership message~%")))))
In a real program, you probably want something more sophisticated than
blocking until a message arrives -- see the function spread:wait which has
an SBCL-specific file-descriptor readiness wait.
DONE:
- multicasting to single groups
- joining and leaving groups
- receiving messages
- (with-mailbox ...) macro
QUESTIONABLE:
- I'm using Scheme-style naming (predicates with '?' rather than '-p') and
I like it
TODO:
- test with Clisp
- test with Spread 4.x
- find tidy syntax for dispatching incoming regular and membership messages
- multicast to multiple groups
- option to reuse message buffer rather than allocating new strings
- non-blocking receive
- test membership messages
- support high performance usage by providing a mode where RECEIVE writes
into a recycled byte vector (like Plokami), rather than allocating new
envelopes and messages
- support Windows?
- support the Java Spread client library for ABCL (?)
- I'm converting the incoming message to a string ignoring encoding
issues for now; in fact the data might be a binary message so this needs
to be improved (optional binary bode with byte vectors?)
- the default private group string generation is stupid (a random number)