at:tutorial:actors
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:actors [2007/07/18 10:09] – elisag | at:tutorial:actors [2007/07/18 11:01] – elisag | ||
---|---|---|---|
Line 172: | Line 172: | ||
===== Futures ===== | ===== Futures ===== | ||
- | 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 to reconcile return values with asynchronous message sends is the notion of a [[Wp> | + | The most well-known language feature |
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 186: | Line 186: | ||
==== Enabling futures ==== | ==== Enabling futures ==== | ||
- | Futures are a frequently recurring language feature in concurrent and distributed languages (for example, in ABCL, the actor-based concurrent language). They are also commonly known by the name of // | + | In AmbientTalk, |
To enable futures, it suffices to import the futures module and to enable it, as follows: | To enable futures, it suffices to import the futures module and to enable it, as follows: | ||
Line 203: | Line 203: | ||
Blocking a thread on a future can be a major source of deadlocks, like any form of blocking, of course. In the actor paradigm where communication between actors should remain strictly asynchronous, | Blocking a thread on a future can be a major source of deadlocks, like any form of blocking, of course. In the actor paradigm where communication between actors should remain strictly asynchronous, | ||
- | The solution proposed in the [[http:// | + | The solution proposed in the [[http:// |
- | + | ||
- | < | + | |
When a future eventually becomes resolved with a value, any messages that were accumulated by the future are forwarded asynchronously to the actual return value, such that it appears as if the original object had sent the messages to the actual return value in the first place. | When a future eventually becomes resolved with a value, any messages that were accumulated by the future are forwarded asynchronously to the actual return value, such that it appears as if the original object had sent the messages to the actual return value in the first place. | ||
+ | <note important> | ||
AmbientTalk only allows one method to be synchronously invoked on a future, the '' | AmbientTalk only allows one method to be synchronously invoked on a future, the '' | ||
+ | </ | ||
==== Working with Resolved Futures ==== | ==== Working with Resolved Futures ==== |
at/tutorial/actors.txt · Last modified: 2020/02/05 21:26 by elisag