User Tools

Site Tools


at:tutorial:distribution

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revisionBoth sides next revision
at:tutorial:distribution [2007/04/26 20:02] elisagat:tutorial:distribution [2007/04/26 20:07] elisag
Line 49: Line 49:
 </code> </code>
  
-The code block to execute when the service type becomes available is parameterized with the actual remote reference to the discovered service object. In the example above, ''messenger'' is a remote reference to the remote object exporting the ''InstantMessenger'' service type. Imagine the interaction between the instant messenger applications executing the above code of two persons, e.g. Bart and Lisa. When the instant messenger of Bart and the instant messenger of Lisa come into one another's communication range, Bart will discover Lisa and Lisa will discover Bart via the ''InstantMessenger'' service type. Then, both will interchange their names and store it in their ''buddyList''. We are using a future to get the return value of the ''getName'' asynchrnonus message invocation. For further details about futures and the ''when:becomes:'' language construct, we refer the reader to the previous section on the concurrency model of AmbientTalk.+The code block to execute when the service type becomes available is parameterized with the actual remote reference to the discovered service object. In the example above, ''messenger'' is a remote reference to the remote object exporting the ''InstantMessenger'' service type. Imagine the interaction between the instant messenger applications executing the above code of two persons, e.g. Bart and Lisa. When the instant messenger of Bart and the instant messenger of Lisa come into one another's communication range, Bart will discover Lisa and Lisa will discover Bart via the ''InstantMessenger'' service type. Then, both will interchange their names and store it in their ''buddyList''. 
 +<note> 
 +We are using a future to get the return value of the ''getName'' asynchrnonus message invocation. For further details about futures and the ''when:becomes:'' language construct, we refer the reader to the previous chapter on the concurrency model of AmbientTalk. 
 +</note>
  
-The observer installed with the ''when:discovered:'' construct will be triggered only once when an ''InstantMessenger'' service type becomes available in the network. In order to be able to discover all other instant messenger buddies available in the network, the ''whenever:discovered:'' construct should be used. As ''when:discovered'', ''whenever:discovered'' takes a service type and a block of code that will be triggered when a remote object of a certain type becomes available in the network. However, the block of code specified in ''whenever:discovered'' can be fired multiple times upon discovering several exported objects. As ''export:as'', both constructs returns a subscription object that responds to a ''cancel'' method that can be used to cancel the subscription so that the block of code is no longer invoked. Note that objects exported by an actor do not trigger the actor's own ''when'' nor ''whenever'' observers.+The ''when:discovered:'' observers will be triggered only once when an ''InstantMessenger'' service type becomes available in the network. In order to be able to discover all other instant messenger buddies available in the network, the ''whenever:discovered:'' construct should be used. As ''when:discovered'', ''whenever:discovered'' takes a service type and a block of code that will be triggered when a remote object of a certain type becomes available in the network. However, the block of code specified in ''whenever:discovered'' can be fired multiple times upon discovering several exported objects.  
 + 
 +As ''export:as'', both constructs returns a subscription object that responds to a ''cancel'' method that can be used to cancel the subscription so that the block of code is no longer invoked. Note that objects exported by an actor do not trigger the actor's own ''when:discovered:'' nor ''whenever:discovered:'' observers.
    
 +
 ===== Partial Failure Handling ===== ===== Partial Failure Handling =====
  
at/tutorial/distribution.txt · Last modified: 2009/01/30 16:13 by tvcutsem