uf:totam
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
uf:totam [2010/10/20 17:17] – Rewriting elisag | uf:totam [2020/04/28 19:41] – adding elisag | ||
---|---|---|---|
Line 17: | Line 17: | ||
TOTAM provides the programmer with means to scope the tuples themselves, i.e the tuples can dynamically adjust their scope as they hop from location to location. By means of tuple space descriptors, | TOTAM provides the programmer with means to scope the tuples themselves, i.e the tuples can dynamically adjust their scope as they hop from location to location. By means of tuple space descriptors, | ||
- | {{: | + | {{: |
Figure above illustrates how a scoped tuple is propagated through the TOTAM network. It depicts two types of locations, the blue and red locations corresponding to two teams of a multi-player game scenario where users (blue team) can use their PDA’s to chase dangerous (virtual) gangsters (red team) in the outdoors. The scope of the propagated tuple has been limited to blue locations. Figure (a) illustrates that a tuple is injected from the location with a star. This location is connected to four blue locations and one red location. As the scope of the tuple is limited to blue locations the tuple is only sent to the four blue locations. From those four locations the tuple is transitively propagated obeying the scope of the tuple until all connected blue locations are reached without being transmitted to a red location. Note that one blue location is not transitively connected to the sending device and thus does not receive the tuple. Figure (b) illustrates that a blue location moved into the range of the isolated blue location and thus, transmits the tuple to it. Again the tuple is not transmitted to nearby red locations. It is important to note from this operational sketch that the first isolated location receives a tuple without being connected at any time with the start location in which the tuple was originally inserted. | Figure above illustrates how a scoped tuple is propagated through the TOTAM network. It depicts two types of locations, the blue and red locations corresponding to two teams of a multi-player game scenario where users (blue team) can use their PDA’s to chase dangerous (virtual) gangsters (red team) in the outdoors. The scope of the propagated tuple has been limited to blue locations. Figure (a) illustrates that a tuple is injected from the location with a star. This location is connected to four blue locations and one red location. As the scope of the tuple is limited to blue locations the tuple is only sent to the four blue locations. From those four locations the tuple is transitively propagated obeying the scope of the tuple until all connected blue locations are reached without being transmitted to a red location. Note that one blue location is not transitively connected to the sending device and thus does not receive the tuple. Figure (b) illustrates that a blue location moved into the range of the isolated blue location and thus, transmits the tuple to it. Again the tuple is not transmitted to nearby red locations. It is important to note from this operational sketch that the first isolated location receives a tuple without being connected at any time with the start location in which the tuple was originally inserted. | ||
- | ==== API ==== | + | |
+ | |||
+ | |||
+ | |||
+ | ===== API ===== | ||
+ | |||
+ | TOTAM has been implemented in AmbientTalk. The system library shipped with AmbientTalk contains the TOTAM implementation under at/ | ||
+ | |||
+ | |||
+ | In order to use TOTAM, you need to load the library and create a TOTAM tuple space as follows: | ||
+ | |||
+ | < | ||
+ | import / | ||
+ | def myTupleSpace := makeTupleSpace(); | ||
+ | </ | ||
+ | |||
+ | A description can be passed in the '' | ||
+ | < | ||
+ | // a “hallo” message tuple from wolf. | ||
+ | def halloTuple := tuple: [" | ||
+ | // a template for message tuples from wolf. | ||
+ | def wolfTuples := tuple: [" | ||
+ | // a template for any message tuples. | ||
+ | def msgTuples := tuple: [" | ||
+ | </ | ||
+ | |||
+ | TOTAM provides operations to add and read tuples from the tuple space as follows: | ||
+ | |||
+ | < | ||
+ | // add tuple to tuple space | ||
+ | myTupleSpace.out(halloTuple); | ||
+ | // get a Message tuple | ||
+ | def aMessageTuple := myTupleSpace.rdp(msgTuples); | ||
+ | // get all Message tuples. | ||
+ | def messageTuples := myTupleSpace.rdg(msgTuples); | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | In the original Linda model, read and in operations were provided to return a copy of the tuple and remove the tuple from the tuple, respectively. Those operations where blocking. TOTAM, inspired by Lime, offers non-blocking variants of these operations: | ||
+ | |||
+ | < | ||
+ | def msgTuples := tuple: [Message, var: `from, var: `content]; | ||
+ | myTupleSpace.whenever: | ||
+ | system.println(“Got message: “ + content + “ from: ” + from); | ||
+ | }; | ||
+ | |||
+ | myTupleSpace.whenever: | ||
+ | system.println(“ “ + from + “ says: “ + content); | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | The '' | ||
+ | |||
+ | < | ||
+ | myTupleSpace.goOnline(); | ||
+ | myTupleSpace.inject: | ||
+ | </ | ||
+ | |||
+ | Note that the network facilities are disabled by default, so before injecting something in the network, the '' | ||
+ | |||
+ | A tuple injected to the network carries the following default propagation protocol. | ||
+ | |||
+ | < | ||
+ | def defaultPropagationProtocol(){ | ||
+ | isolate: { | ||
+ | // | ||
+ | def decideEnter(ts) { true }; | ||
+ | def doAction(ts){}; | ||
+ | def changeTupleContent(ts){self}; | ||
+ | def decideStore(ts) {true}; | ||
+ | // | ||
+ | def inScope(senderDescriptor, | ||
+ | def decideDie(ts){false}; | ||
+ | }; | ||
+ | }; | ||
+ | </ | ||
+ | |||
+ | However, other propagation protocols can be created and attached to a tuple before being injected in the network as follows: | ||
+ | |||
+ | < | ||
+ | //define a new propagation protocol | ||
+ | def blueProtocol := propagationProtocol: | ||
+ | def inScope(senderDescriptor, | ||
+ | receiverDescriptor.team == " | ||
+ | }; | ||
+ | // attach the protocol to a tuple | ||
+ | def aBlueTuple := tuple: [" | ||
+ | withPropagationProtocol: | ||
+ | // inject the tuple to the network | ||
+ | def publication := inject: aBlueTuple; | ||
+ | </ | ||
+ | |||
+ | The '' | ||
+ | |||
+ | < | ||
+ | // sends an antituple to notify the removal of this tuple. | ||
+ | publication.retract(); | ||
+ | </ | ||
+ | |||
+ | Upon a '' | ||
+ | |||
+ | |||
+ | < | ||
+ | Note that '' | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
Line 29: | Line 140: | ||
([[ http:// | ([[ http:// | ||
- | + | < | |
+ | </ |
uf/totam.txt · Last modified: 2021/09/24 10:49 by elisag