[e-lang] inter-vat promises

Mark S. Miller markm at cs.jhu.edu
Tue May 8 17:35:11 EDT 2007


Tony Finch wrote:
> If I say something like
> 
> 	def [promise,resolver] := Ref.promise()
> 	alice <- resolve(resolver)
> 	bob <- resolve(resolver)
> 
> where alice and bob are in different remote vats, how is the race between
> the two attempts to resolve the promise handled? I saw mention on the
> erights site that it distinguishes local and cross-site promises, so I
> guess that after the send to alice the reolver has changed, and that bob
> gets a different kind of thing to alice. Perhaps the promise only ever has
> one end that can be resolved at any time?

A resolver is itself a normal E pass-by-proxy object, so the above code does
not create any remote promises. Say the code above is executed in vatC. Then
the promise and resolver it creates are local to vatC. alice and bob are each
given far references to that resolver. If they both eventual-send resolve
messages to it, whichever one arrives first will cause it to resolve to the
answer.

There are two ways to create a remote promise: when sending a message to a
remote object, the promise for the result of the message is a remote promise.

     def remotePromise := alice <- foo()

Here, the remotePromise is on vatC but its resolver is on vatA. In E, alice
does not obtain direct access to this resolver. Rather, if she wants to
effectively reify this resolver, she can do:

     to foo() {
         def [result,resolver] := Ref.promise()
         # ... resolver ...
         return result
     }

By returning the new local promise as the result and holding on to the
resolver, the remote promise is now unified with this local promise, using up
the hidden resolver. The new resolver is now effectively the resolver for the
original promise.

The other way is by passing a local promise in an argument in a remote message:

     def [p,r] := Ref.promise()
     alice <- foo(p)

Here, alice in vatA receives a remote promise unified with the local promise
created above on vatC. Resolver r acts effectively as the resolver for both
promises.

Does this answer your question?

May I post this correspondence to e-lang?

-- 
Text by me above is hereby placed in the public domain

     Cheers,
     --MarkM



More information about the e-lang mailing list