Futures and Promises - Semantics of Futures in The Actor Model

Semantics of Futures in The Actor Model

In the Actor model, an expression of the form future is defined by how it responds to an Eval message with environment E and customer C as follows: The future expression responds to the Eval message by sending the customer C a newly created actor F (the proxy for the response of evaluating ) as a return value concurrently with sending an Eval message with environment E and customer F. The default behavior of F is as follows:

  • When F receives a request R, then it checks to see if it has already received a response (that can either be a return value or a thrown exception) from evaluating proceeding as follows:
    1. If it already has a response V, then
      • If V is a return value, then it is sent the request R.
      • If V is an exception, then it is thrown to the customer of the request R.
    2. If it does not already have a response, then R is stored in the queue of requests inside the F.
  • When F receives the response V from evaluating , then V is stored in F and
    • If V is a return value, then all of the queued requests are sent to V.
    • If V is an exception, then it is thrown to the customer of the each queued request.

However, some futures can deal with requests in special ways to provide greater parallelism. For example, the expression 1 + future factorial(n) can create a new future that will behave like the number 1+factorial(n). This trick does not always work. For example the following conditional expression:

if m>future factorial(n) then print("bigger") else print("smaller")

suspends until the future for factorial(n) has responded to the request asking if m is greater than itself.

Read more about this topic:  Futures And Promises

Famous quotes containing the words futures, actor and/or model:

    One of the things that is most striking about the young generation is that they never talk about their own futures, there are no futures for this generation, not any of them and so naturally they never think of them. It is very striking, they do not live in the present they just live, as well as they can, and they do not plan. It is extraordinary that whole populations have no projects for a future, none at all.
    Gertrude Stein (1874–1946)

    As soon as I suspect a fine effect is being achieved by accident I lose interest. I am not interested ... in unskilled labor.... The scientific actor is an even worker. Any one may achieve on some rare occasion an outburst of genuine feeling, a gesture of imperishable beauty, a ringing accent of truth; but your scientific actor knows how he did it. He can repeat it again and again and again. He can be depended on.
    Minnie Maddern Fiske (1865–1932)

    One of the most important things we adults can do for young children is to model the kind of person we would like them to be.
    Carol B. Hillman (20th century)