at:tutorial:distribution
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
at:tutorial:distribution [2007/06/19 16:09] – tvcutsem | at:tutorial:distribution [2008/09/16 17:28] – added tvcutsem | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | < | ||
- | This tutorial is under heavy construction! | ||
- | </ | ||
- | |||
====== Distributed Programming ====== | ====== Distributed Programming ====== | ||
- | This tutorial | + | Building on the actor-based concurrency model explained in the [[actors|previous chapter]], this chapter discusses |
- | The integration | + | |
- | More specifically, | + | These requirements correspond |
- | ===== Starting the Network.. | + | Before delving in these topics, we illustrate how to activate the network facilities of AmbientTalk in the next section. |
+ | |||
+ | ===== Going Online | ||
AmbientTalk provides an unique native object, named '' | AmbientTalk provides an unique native object, named '' | ||
- | When the virtual machine goes online, | + | When the virtual machine goes online, the built-in |
+ | |||
+ | Taking a virtual machine | ||
< | < | ||
Line 26: | Line 25: | ||
deftype Printer; | deftype Printer; | ||
def service := object: { | def service := object: { | ||
- | def print(aDoc) { | + | |
- | system.println(" | + | system.println(" |
- | } | + | } |
}; | }; | ||
export: service as: Printer; | export: service as: Printer; | ||
Line 47: | Line 46: | ||
< | < | ||
when: InstantMessenger discovered: { |messenger| | when: InstantMessenger discovered: { |messenger| | ||
- | when: (messenger< | + | |
- | buddyList.put(name, | + | buddyList.put(name, |
- | system.println(" | + | system.println(" |
- | | + | }; |
}; | }; | ||
</ | </ | ||
Line 63: | Line 62: | ||
As '' | As '' | ||
- | |||
===== Partial Failure Handling ===== | ===== Partial Failure Handling ===== | ||
Line 76: | Line 74: | ||
When a remote far reference receives a messages, it flushes the message to the remote object providing that it is connected. If the remote far reference is disconnected, | When a remote far reference receives a messages, it flushes the message to the remote object providing that it is connected. If the remote far reference is disconnected, | ||
- | Therefore, a remote far reference abstracts a client object from the actual network connection state. However, it is often useful for an application to be informed when a connection to a remote object is lost or reconnected. To this end, AmbientTalk offers language constructs to install observers on a far reference which are triggered | + | Therefore, a remote far reference abstracts a client object from the actual network connection state. However, it is often useful for an application to be informed when a connection to a remote object is lost or reconnected. To this end, AmbientTalk offers language constructs to install observers on a far reference which are triggered |
< | < | ||
when: InstantMessenger discovered: { |messenger| | when: InstantMessenger discovered: { |messenger| | ||
- | ... | + | |
- | when: messenger disconnected: | + | |
- | system.println(" | + | system.println(" |
- | }; | + | }; |
- | when: messenger reconnected: | + | |
- | system.println(" | + | system.println(" |
- | }; | + | }; |
}; | }; | ||
</ | </ | ||
Line 92: | Line 90: | ||
This code illustrate how the instant messenger application notifies when a buddy goes online or offline. In the above code, '' | This code illustrate how the instant messenger application notifies when a buddy goes online or offline. In the above code, '' | ||
- | In other to cope with partial failures, AmbientTalk also allows developers to retract all currently unsent messages from the far reference outbox by means of the '' | + | In order to cope with partial failures, AmbientTalk also allows developers to retract all currently unsent messages from the far reference outbox by means of the '' |
The '' | The '' | ||
Line 98: | Line 96: | ||
< | < | ||
when: Service discovered: { | reference | | when: Service discovered: { | reference | | ||
- | | + | |
- | | + | messages := retract: reference; |
- | } | + | } |
} | } | ||
</ | </ | ||
The construct returns a table containing copies of all messenges that were sent to this far reference, but not yet transmitted by the far reference to the remote object pointed to. Note that this has the side effect that the returned messages will not be sent automatically anymore; the programmer is thus responsible to explicitly resend all messages that were retracted but still need to be sent. | The construct returns a table containing copies of all messenges that were sent to this far reference, but not yet transmitted by the far reference to the remote object pointed to. Note that this has the side effect that the returned messages will not be sent automatically anymore; the programmer is thus responsible to explicitly resend all messages that were retracted but still need to be sent. | ||
+ | |||
+ | The function '' | ||
===== Garbage collecting remote references ===== | ===== Garbage collecting remote references ===== | ||
+ | |||
+ | < | ||
+ | This is an advanced topic and probably does not belong in the tutorial. Moreover, it discusses features to be used only by implementors of reflective language constructs. | ||
+ | </ | ||
As explained in the previous section, AmbientTalk' | As explained in the previous section, AmbientTalk' | ||
Line 124: | Line 128: | ||
< | < | ||
when: messenger takenOffline: | when: messenger takenOffline: | ||
- | system.println(" | + | |
- | | + | //clean certain resources associated to the buddy |
}; | }; | ||
</ | </ |
at/tutorial/distribution.txt · Last modified: 2009/01/30 16:13 by tvcutsem