User Tools

Site Tools


uf:totam

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
uf:totam [2012/03/27 11:06]
jorge
uf:totam [2021/09/24 10:49] (current)
elisag [Creating a tuplespace and tuples]
Line 20: Line 20:
  
 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 =====
Line 25: Line 29:
 TOTAM has been implemented in AmbientTalk. The system library shipped with AmbientTalk contains the TOTAM implementation under at/lang/totam.at. TOTAM has been implemented in AmbientTalk. The system library shipped with AmbientTalk contains the TOTAM implementation under at/lang/totam.at.
  
 +==== Creating a Tuplespace and Tuples ====
  
 In order to use TOTAM, you need to load the library and create a TOTAM tuple space as follows: In order to use TOTAM, you need to load the library and create a TOTAM tuple space as follows:
Line 33: Line 38:
 </code>  </code> 
  
-A description can be passed in the ''makeTupleSpace'' operation in order to activate the scoping mechanism (as we will explain later).  To create a tuple or a template, the tuple operation can be used as follows:+A description can be passed in the ''makeTupleSpace'' operation in order to activate the scoping mechanism (as we will explain later).   
 + 
 +To create a tuple or a template (i.e. a tuple with wildcards or "holes"), the 'tuple:' operation can be used as follows:
 <code>  <code> 
 // a “hallo” message tuple from wolf. // a “hallo” message tuple from wolf.
-def halloTuple := tuple: [Message, “wolf”, “hallo”];+def halloTuple := tuple: ["Message", “wolf”, “hallo”];
 // a template for message tuples from wolf. // a template for message tuples from wolf.
-def wolfTuples := tuple: [Message, “wolf”, var: `content];+def wolfTuples := tuple: ["Message", “wolf”, var: `content];
 // a template for any message tuples. // a template for any message tuples.
-def msgTuples := tuple: [Message, var: `from, var: `content];+def msgTuples := tuple: ["Message", var: `from, var: `content];
 </code> </code>
 +
 +
 +==== Adding and Reading Tuples ====
  
 TOTAM provides operations to add and read tuples from the tuple space as follows: TOTAM provides operations to add and read tuples from the tuple space as follows:
Line 54: Line 64:
 </code> </code>
  
-The ''rdp(template)'' and ''rdg(template)'' operations return a tuple or all tuples matching the template in the tuple space if present (without removing), respectively.  +The ''rdp(template)'' and ''rdg(template)'' operations return a tuple or all tuples matching the template in the tuple space if present (without removing), respectively. Note that if no tuple is present matching the template, ''nil'' is given back.  
-Note that these operations are non-blocking. The'' out(tuple)'' operation to insert a private tuple in the tuple space. In order for applications to insert a public tuple, thereby making it available to other collocated TOTAM systems, the'' inject:'' operation is provided.+ 
 +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: 
 + 
 +<code> 
 +def msgTuples := tuple: [Message, var: `from, var: `content]; 
 +myTupleSpace.whenever: msgTuples read:{ 
 +  system.println(“Got message: “ + content + “ from: ” + from); 
 +}; 
 + 
 +myTupleSpace.whenever: wolfTuples in:{   
 +  system.println(“ “ + from + “ says: “ + content); 
 +}; 
 +</code> 
 + 
 +The ''whenever:read:'' operation takes as parameter a template and a block closure which is asynchronously applied each time a tuple matching the template is added to the tuple space. The ''whenever:in:'' operation works similarly but it also removes the tuple matching the template. Following Linda's in semantics, if several ''whenever:in:'' operations could be triggered for one tuple, //only// one of them will succeed. Variables specified in the template are bound in the body of the block closure to the concrete value of the tuple that matched the template. Both operations return a subscription object which understands a ''cancel'' message to stop the interest in tuples matching the template. Note also that both operations have a ''when:'' variant which only triggers once the block closure for the first tuple that matches the template. 
 + 
 +The ''out(tuple)'' operation actually inserts a private tuple in the tuple space. In order for applications to insert a public tuple, thereby making it available to other collocated TOTAM systems, the'' inject:'' operation is provided.
  
 <code> <code>
Line 64: Line 90:
 Note that the network facilities are disabled by default, so before injecting something in the network, the ''goOnline()'' method must be called on the tuple space. Note that the network facilities are disabled by default, so before injecting something in the network, the ''goOnline()'' method must be called on the tuple space.
  
-tuple injected to the network carries the following default propagation protocol.+==== Tuple's Propagation Protocol ==== 
 + 
 +Similar to TOTA, public tuples are replicated and shared amongst devices when devices come into communication range. We thus say that tuple are propagated into the //TOTAM network//, i.e. a logical network formed by all devices which host a TOTAM tuple space. The spread of tuples into the TOTAM network can be controlled by means of a propagation protocol. Each tuple injected into the network carries a propagation protocol that can be customized by developers. What follows shows the default propagation protocol:
  
 <code> <code>
Line 81: Line 109:
 </code> </code>
  
-However, other propagation protocols can be created and attached to a tuple before being injected in the network as follows:+Custom propagation protocols can be created and attached to a tuple before being injected in the network as follows:
  
 <code> <code>
Line 90: Line 118:
 }; };
 // attach the protocol to a tuple // attach the protocol to a tuple
-def aBlueTuple := tuple: [Message, "hallo"]  +def aBlueTuple := tuple: ["Message", "hallo"]  
-withPropagationProtocol: blueProtocol};+withPropagationProtocol: blueProtocol;
 // inject the tuple to the network // inject the tuple to the network
 def publication := inject: aBlueTuple; def publication := inject: aBlueTuple;
 </code> </code>
  
-The ''propagationProtocol:'' operation creates a propagation protocol object which extends the default propagation protocol object with other semantics. this sample code shows a protocol based on the operational sketch figure that checks whether the receiver of the tuple is part of the blue team. This is attached to the tuple by means of the ''tuple:withPropagationProtocol:'' operation which is then injected into the network. The inject: operation returns a publication object which can be used as follows to remove the tuple from the network.+The ''propagationProtocol:'' operation creates a propagation protocol object which extends the default propagation protocol object with other semantics. this sample code shows a protocol based on the operational sketch figure that checks whether the receiver of the tuple is part of the blue team. This is attached to the tuple by means of the ''tuple:withPropagationProtocol:'' operation which is then injected into the network. The ''inject:'' operation returns a publication object which understands two methods:  
  
 <code> <code>
-// sends an antituple to notify the removal of this tuple.+// cancels the propagation of the tuple to new devices in the TOTAM network. 
 +publication.cancel(); 
 +// sends an antituple to notify the removal of this tuple in devices which carry a copy.
 publication.retract(); publication.retract();
 </code> </code>
  
-In order to notify the removal of tuple, TOTAM sends an antituple for the removed tuple. For every tuple there is (conceptually) a unique antituple with the same format and content, but with a different sign. All tuples injected by an application have positive sign while their antituples have a negative sign. Whenever a tuple and its antituple are stored in the same tuple space, they immediately annihilate one another, i.e. they both get removed from the tuple space. By means of antituples, TOTAM can “unsend” tuples injected to the network.+Upon a ''cancel'' operation, TOTAM stops the injection of the tuple into newly discovered devices in the TOTAM network.  
 +Upon a ''retract'' operation, TOTAM injects in the TOTAM network an antituple for the removed tuple. For every tuplethere is (conceptually) a unique antituple with the same format and content, but with a different sign. All tuples injected by an application have positive sign while their antituples have a negative sign. Whenever a tuple and its antituple are stored in the same tuple space, they immediately annihilate one another, i.e. they both get removed from the tuple space. By means of antituples, TOTAM can “unsend” tuples injected into the network.
  
  
 +<note>
 +Note that ''retract'' is meant to be used by the creator of a tuple to stop the propagation of a tuple and remove it from the network. This is useful in cases that tuples injected carry outdate information. However, this operation should **not** be confused with the ''when:in:'' operation which allows applications to read and remove a tuple matching a template from the TOTAM network. 
 +</note>
  
  
Line 117: Line 152:
 ([[ http://prog.vub.ac.be/Publications/2009/vub-prog-tr-09-07.pdf | pdf]]) ([[ http://prog.vub.ac.be/Publications/2009/vub-prog-tr-09-07.pdf | pdf]])
  
-Note: The paper above and this webpage may have differ in the syntax for TOTAM. This webpage has been updated to fit the current implementation of TOTAM.+<note>The paper above and this webpage may have slightly differ in the syntax for TOTAM. This webpage has been updated to fit the current implementation of TOTAM. 
 +</note>
uf/totam.1332839211.txt.gz · Last modified: 2012/04/16 21:21 (external edit)