at:tutorial:actors
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
at:tutorial:actors [2008/11/04 10:11] – added tvcutsem | at:tutorial:actors [2020/02/05 21:26] (current) – elisag | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | |||
====== Concurrent Programming with Actors ====== | ====== Concurrent Programming with Actors ====== | ||
Line 179: | Line 178: | ||
As you may have noticed previously, asynchronous message sends do not return any value (that is, they return '' | As you may have noticed previously, asynchronous message sends do not return any value (that is, they return '' | ||
+ | |||
+ | |||
+ | |||
==== The Concept ==== | ==== The Concept ==== | ||
- | The most well-known language feature in concurrent and distributed languages (for example, in ABCL, the actor-based concurrent language) to reconcile return values with asynchronous message sends is the notion of a [[Wp> | + | The most well-known language feature in concurrent and distributed languages (for example, in ABCL, the actor-based concurrent language) to reconcile return values with asynchronous message sends is the notion of a [[Wp> |
+ | |||
+ | Futures are objects that represent return values that may not yet have been computed. Once the asynchronously invoked method has completed, the future is replaced with the actual return value, and objects that referred to the future transparently refer to the return value. | ||
Using futures, it is possible to re-implement the previous example of requesting our calculator actor to add two numbers as follows: | Using futures, it is possible to re-implement the previous example of requesting our calculator actor to add two numbers as follows: | ||
Line 189: | Line 193: | ||
def sum := calculator< | def sum := calculator< | ||
</ | </ | ||
+ | |||
==== Enabling futures ==== | ==== Enabling futures ==== | ||
Line 201: | Line 206: | ||
</ | </ | ||
- | The first statement imports the futures module into the current lexical scope. This enables you as a developer to use some additional language constructs exported by the futures module, as will be explained later. The second statement enables the futures behaviour, causing any asynchronous message send to return a future rather than '' | + | The first statement imports the futures module into the current lexical scope. This enables you as a developer to use some additional language constructs exported by the futures module, as will be explained later. The second statement enables the futures behaviour, causing any asynchronous message send to return a future rather than '' |
- | More information pertaining to the API of the futures language module can be found in the [[: | + | < |
+ | In what follows we provide an overview on how to work with futures. | ||
+ | </ | ||
==== Working with Unresolved Futures ==== | ==== Working with Unresolved Futures ==== | ||
Line 306: | Line 313: | ||
As previously explained, there are two modes for enabling futures in AmbientTalk. Invoking '' | As previously explained, there are two modes for enabling futures in AmbientTalk. Invoking '' | ||
- | When a message send is annotated with the '' | + | When a message send is annotated with the '' |
< | < | ||
- | o<-m()@OneWayMessage | + | o<-m()@OneWay |
</ | </ | ||
- | When a message send is annotated with the '' | + | When a message send is annotated with the '' |
< | < | ||
- | o<-m()@FutureMessage | + | o<-m()@TwoWay |
</ | </ | ||
+ | |||
+ | When a message send is annotated with the '' | ||
+ | |||
+ | < | ||
+ | o< | ||
+ | </ | ||
+ | |||
+ | < | ||
+ | More details about the '' | ||
+ | </ | ||
Finally, it is possible to first invoke '' | Finally, it is possible to first invoke '' | ||
Line 469: | Line 486: | ||
</ | </ | ||
- | If both the '' | + | If both the '' |
- | Recall that isolates could be given selective | + | Recall that isolates could be given access to their enclosing lexical scope either |
< | < |
at/tutorial/actors.1225789878.txt.gz · Last modified: 2008/11/04 10:16 (external edit)