(c0, c1, ...)
("hello", 1.0) doesn't match(1, "hello").
("good-bye", 1.0) doesn't match("hello", 1.0).
get(c0, c1, ...) gets a matching tuple from the tuple space.
ci.
ci is ?variable, the corresponding tuple
coordinate is assigned to variable.
get() blocks until a matching tuple is available.
try_get() returns false if no tuple matches.
get() removes the matching tuple from the tuple space.
look() matches and doesn't remove a tuple.
try_look() is nonblocking.
put(c0, c1, ...) adds a tuple with the given
coordinates to the tuple space.
eval(c0, c1, ...) adds a
process tuple
to the tuple space.
eval() doesn't reveal intermediate tuple states.
("partner?", receiverIndex, senderIndex)
("accepted", receiverIndex, senderIndex)
("declined", receiverIndex, senderIndex)
while neighbors != { }
get(msg, nodeIndex, senderIndex)
neighbors.remove(senderIndex)
if msg == "partner?"
assert senderIndex > nodeIndex
partnerIndex = senderIndex
put("accepted", senderIndex, nodeIndex)
break
assert msg == "declined"
assert senderIndex < nodeIndex
foreach nbr in neighbors
if nbr.nodeIndex > nodeIndex
put("declined", nbr.nodeIndex, nodeIndex)
neighbors.remove(nbr)
if partnerIndex == nodeIndex
foreach nbr in neighbors
assert nbr.nodeIndex < nodeIndex
put("partner?", nbr.nodeIndex, nodeIndex)
get(msg, nodeIndex, nbr.nodeIndex)
if (msg == "accepted")
partnerIndex = nbr.nodeIndex
break
assert msg == "declined"
public class Message
implements Entry
public String content
public Message() { }
message msg = new Message() msg.content = "Hello world!"
package net.jini.spaces
public interface JavaSpace
EventRegistration notify(
Entry tmpl, Transaction txn,
RemoteEventListener listener,
long lease, MarshalledObject handback)
Entry read(
Entry tmpl, Transaction txn, long timeout)
Entry readIfExists(
Entry tmpl, Transaction txn, long timeout)
Entry take(
Entry tmpl, Transaction txn, long timeout)
Entry takeIfExists(
Entry tmpl, Transaction txn, long timeout)
Lease write(
Entry entry, Transaction txn, long lease)
// There are others.
JavaSpace space = SpaceAccessor.getSpace() space.write( // to this space msg, // write this tuple null, // in no transaction Lease.FOREVER) // to last forever
Message result = // Into this tuple
(Message) // a message
space.read( // read from this space
new Message(), // with any content
null, // under no transaction
Long.MAX_VALUE) // wait this long
EventRegistration watcher =
notify(
tpl, // look for this tuple
txn, // as part of this transaction
listener, // calling this listener
lease, // until this expires
handback) // passing this to the listener
This page last modified on 12 August 2003.