[e-lang] [Fwd: Re: inter-vat promises]

Mark S. Miller markm at cs.jhu.edu
Tue May 8 18:03:12 EDT 2007


Tony Finch wrote:
> [...]  it makes me wonder what happens to an attempt to
> resolve a promise that is already resolved.

Such an attempt using the normal resolve/1 method will throw an exception. (If 
you intend to race to resolve the resolver on purpose, you can instead call 
resolver(target, false) to suppress this exception.)


> This usually happens when a
> turn completes and the only result of the turn is to resolve the promise,
> so the error can't be reported to the resolver.

In this case, for a program written in the normal way in E, this problem can't 
happen since the resolver implicitly resolved by that turn's outcome is not 
otherwise available to E code.


> I suppose it's fairly easy for the programmer to avoid this problem by
> using promises in a linear way (i.e. so that an object which passes
> the resolver to another object never subsequently uses the resolver).

In some sense, E's turn discipline imposes such linearity on the resolvers 
implicitly created to report turn outcomes.


> Also, I'm not entirely sure what the LocalPromise <-> RemotePromise
> transitions in the reference state transition diagram refer to. 

Let's say we're in vatC, pa1 is a remote promise in vatC whose resolver is in 
vatA, and ra2 is a resolver in vatC for a different remote promise in vatA.

Given:

     def [pc,rc] := Ref.promise()

which creates a promise local to vatC, were we to do

     rc.resolve(pa1)

then pc would become a remote promise identical to pa1, whose resolver is 
pa1's resolver in vatA. this is the LocalPromise->RemotePromise transition.

Alternatively, were we to do

     ra2.resolve(pa1)

then ra2's remote promise in VatA would become a promise local to vatA whose 
resolver is pa1's resolver in vatA. This is the RemotePromise->LocalPromise 
transition.


> How are
> remote promises different from a promise with one end passed by proxy to
> another vat?

A resolver is just a normal pass-by-proxy object. Passing it to another vat 
does not change anything -- the other vat simply has a remote reference to the 
original resolver, which is still where it was. Passing a promise to another 
vat does generally create a remote promise, whose resolver is the same as the 
original promise's resolver. But not always. As another alternative, were we to do

     alice <- foo(pa1)

Alice would receive this argument as a promise local to vatA.

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

     Cheers,
     --MarkM


More information about the e-lang mailing list