Miranda whenMoreResolved

From Erights

(Difference between revisions)
Jump to: navigation, search
(clean up, incorporate javadoc)
Line 1: Line 1:
-
'''__whenMoreResolved/1''' is a [[Miranda message]].
+
<code>__whenMoreResolved/1</code> is a Miranda message.
{{instance msgdoc|__whenMoreResolved|1|<var>reactor</var> :[[OneArgFunc]]|[[void]]}}
{{instance msgdoc|__whenMoreResolved|1|<var>reactor</var> :[[OneArgFunc]]|[[void]]}}
-
Notify the <var>reactor</var> when the reference is resolved, or is importantly ''closer'' to being resolved; specifically when it has become the [[same]] as a reference into a different vat (is a candidate for [[shortening]]).
+
The overall effect is to notify the <var>reactor</var> when the reference is resolved, or is ''closer'' to being resolved — in particular, when a resolution has changed its target to another vat. {{XXX|poor terminology}}
-
* If the recipient is a [[near ref]], then the Miranda method should be:
+
If the recipient is a [[near ref]], then the Miranda method should be:
  to __whenMoreResolved(reactor) {
  to __whenMoreResolved(reactor) {
     reactor &lt;- run(<var>recipient</var>)
     reactor &lt;- run(<var>recipient</var>)
     return null
     return null
  }
  }
-
* If the recipient is a [[local promise]] then it should buffer and forward the message normally.
 
-
* If the recipient is a [[remote promise]] then {{XXX|Specify the CapTP-related behavior.}}
 
-
 
-
==Original Javadoc==
 
-
 
-
{{XXX|merge}}
 
-
 
-
Used to implement when-catch and the "[[Ref#whenResolved/2]]"; it should not
 
-
be called directly.
 
-
 
-
The Miranda behavior responds by doing 'reactor &lt;- run(self)'. If the
 
-
reference never becomes resolved, the reactor is not invoked.
 
-
 
-
In the cooperative (non-malicious) case, the reactor will not be invoked
 
-
more than once.
 
-
 
-
When sent on a reference, once the reference becomes resolved the
 
-
reactor will be invoked with the resolution. Should the reactor be
 
-
invoked with a non-broken reference, all earlier messages are guaranteed
 
-
to have been successfully delivered.
 
-
 
-
Should the reference become broken, or should breakage prevent the
 
-
reporting of fulfillment to the reactor, the reactor will be invoked
 
-
with a broken reference. The reactor may be invoked more than once. In
 
-
particular, if the reference becomes fulfilled and then broken, the
 
-
reactor may hear of either or both of these events.
 
-
 
-
See also: [[Ref#whenBroken/2]]
 
-
 
-
==Tests==
 
  ? var r := null
  ? var r := null
  > def ret := 1 <- __whenMoreResolved(fn x { r := x + 1 })
  > def ret := 1 <- __whenMoreResolved(fn x { r := x + 1 })
-
> interp.waitAtTop(ret)
 
-
> ret
 
  # value: <Promise>
  # value: <Promise>
   
   
Line 54: Line 22:
{{XXX|Above tests do not check for reactor&lt;-run rather than reactor.run}}
{{XXX|Above tests do not check for reactor&lt;-run rather than reactor.run}}
 +
 +
If the recipient is a [[local promise]] then it should buffer and forward the message normally.
 +
 +
If the recipient is a [[remote promise]] then {{XXX|Specify the CapTP-related behavior.}}
[[Category:Miranda messages]]
[[Category:Miranda messages]]
[[Category:Pluribus]]
[[Category:Pluribus]]

Revision as of 15:51, 10 June 2009

__whenMoreResolved/1 is a Miranda message.

__whenMoreResolved/1

Signature: __whenMoreResolved(reactor :OneArgFunc) :void

The overall effect is to notify the reactor when the reference is resolved, or is closer to being resolved — in particular, when a resolution has changed its target to another vat. XXX poor terminology

If the recipient is a near ref, then the Miranda method should be:

to __whenMoreResolved(reactor) {
    reactor <- run(recipient)
    return null
}
? var r := null
> def ret := 1 <- __whenMoreResolved(fn x { r := x + 1 })
# value: <Promise>

? r
# value: 2

? [ret]
# value: [null]

XXX Above tests do not check for reactor<-run rather than reactor.run

If the recipient is a local promise then it should buffer and forward the message normally.

If the recipient is a remote promise then XXX Specify the CapTP-related behavior.

Personal tools
more tools