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/remote-mailbox-threads|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. [[tags: egg]] == remote-mailbox-threads [[toc:]] === Description This is an extension of the [[mailbox-threads]] egg to allow communication between remote threads via [[zmq]]. By default, the Scheme {{write}}/{{read}} procedures are used for serialization so not all objects can be sent. You may want to override the {{serializer}}/{{deserializer}} parameters to [[s11n]]'s {{serialize}}/{{deserialize}} functions to be able to send record, lambdas etc. === Author [[/users/moritz-heidkamp|Moritz Heidkamp]] === Requirements [[zmq]] and [[mailbox-threads]] === Documentation All procedures exported by [[mailbox-threads]] are also exported by {{remote-mailbox-threads}}, the only difference being that {{thread-send}} can also send messages to remote threads (see {{connect-remote-thread}} on how to connect to a remote thread). The functions documented here are only those which are provided additionally. <procedure>(publish-thread! thread . endpoints)</procedure> Publish {{thread}} via {{endpoints}} (a list of [[zmq]] endpoint strings). For each invocation of {{publish-thread!}} a thread with a message loop for the given endpoints is started. <procedure>(connect-remote-thread . endpoints)</procedure> Connect to remote thread(s) at {{endpoints}} (a list of [[zmq]] endpoint strings). The return value will be a {{remote-thread}} record which can be sent messages just like normal threads using {{thread-send}}. The remote threads must be published by using {{publish-thread!}} at the remote side. If more than one endpoint is given in {{endpoints}}, messages will be sent round-robin style thus you should make sure that all messages sent to the remote thread can be handled by any of the given {{endpoints}}. <parameter>(serializer [FN])</parameter> The function used for serializing objects which are to be sent. It must accept one argument (the object to be serialized) and write the serialized representation to {{(current-output-port)}}. Default: {{write}}. <parameter>(deserializer [FN])</parameter> The function used for deserializing received messages. It should read the serialized data stream from {{(current-input-port)}} and return the deserialized object. Default: {{read}}. === Example Consumer: <enscript language="scheme"> (use remote-mailbox-threads) (publish-thread! (current-thread) "tcp://127.0.0.1:12345" "ipc:///tmp/nomnom") (print "waiting for things to consume") (let loop ((msg (thread-receive))) (display "nom nom nom: ") (print msg) (loop (thread-receive))) </enscript> Producer: <enscript language="scheme"> (use remote-mailbox-threads) (define consumer (connect-remote-thread "tcp://127.0.0.1:12345")) (define another-consumer (connect-remote-thread "ipc:///tmp/nomnom")) (thread-send consumer 'carrot) (thread-send another-consumer 'egg) </enscript> Note that the producer connects two different remote threads, both of which refer to the same exported thread of the consumer. === License Copyright (c) 2010-2012, Moritz Heidkamp All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you subtract 0 from 3?