User Tools

Site Tools


at:tutorial:actors

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:actors [2008/03/13 16:41] – * tvcutsemat:tutorial:actors [2008/03/13 16:49] – added tvcutsem
Line 204: Line 204:
  
 The solution proposed in the [[http://www.erights.org|E language]], and adopted in AmbientTalk, is to disallow direct access to a future by any object. Instead, objects may **only** send **asynchronous** messages to a future object. This enables the future to temporarily buffer such messages until its resolved value is known. The net effect of this solution is that futures actually can be "chained", forming asynchronous //pipelines// of messages, as will be illustrated in the next section. The solution proposed in the [[http://www.erights.org|E language]], and adopted in AmbientTalk, is to disallow direct access to a future by any object. Instead, objects may **only** send **asynchronous** messages to a future object. This enables the future to temporarily buffer such messages until its resolved value is known. The net effect of this solution is that futures actually can be "chained", forming asynchronous //pipelines// of messages, as will be illustrated in the next section.
 +
 +As an example of a pipeline of message sends, consider the following code:
 +
 +<code>
 +def booleanFuture := remoteObject<-ask(something);
 +booleanFuture<-ifTrue: {
 +  ...
 +} ifFalse: {
 +  ...
 +}
 +</code>
 +
 +In this example, the message ''ifTrue:ifFalse:'' is sent to a future which will be resolved with a boolean object (the answer to the ''ask'' method). When the ''booleanFuture'' becomes resolved, it will forward the message to its resolved value. The above code shows how you can postpone the execution of code until a future becomes resolved. However, this particular synchronisation technique only works for (futures for) booleans. The following section describes a more general synchronisation technique to await the value of a future for any kind of value.
  
 ==== Working with Resolved Futures ==== ==== Working with Resolved Futures ====
at/tutorial/actors.txt · Last modified: 2020/02/05 21:26 by elisag