org.erights.e.elib.ref
Class LocalResolver

java.lang.Object
  |
  +--org.erights.e.elib.ref.LocalResolver
All Implemented Interfaces:
Resolver

class LocalResolver
extends Object
implements Resolver

The arrowhead facet of a local promise for resolving the outcome of the promise.

Author:
Mark S. Miller

Field Summary
private  FlexList myOptBuf
          Until the promise is done, this holds the buffer of all messages sent to far.
private  Ref myOptRef
          Once it's done, it stops pointing at the Ref.
 
Constructor Summary
(package private) LocalResolver(Ref sRef, FlexList buf)
          Makes (what should be) the one resolver for resolving sRef.
 
Method Summary
 boolean isDone()
          Enabled: If not isDone(), both resolveRace(java.lang.Object) and smash(java.lang.Throwable) will work and return true, and resolve(java.lang.Object) will work rather than throw an exception.
 void resolve(Object target)
          Enabled: Like resolveRace(java.lang.Object), but throws an exception to report that this Resolver was already resolved, rather than returning a boolean.
 boolean resolveRace(Object target)
          Enabled: Queues all accumulated and future messages for delivery to target, and, for example, a local promise becomes resolved into being E-equivalent to the target.
 boolean smash(Throwable problem)
          Enabled: Breaks the promise, reporting 'problem' as the reason.
 String toString()
          Suppressed: Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myOptRef

private Ref myOptRef
Once it's done, it stops pointing at the Ref.


myOptBuf

private FlexList myOptBuf
Until the promise is done, this holds the buffer of all messages sent to far.

Constructor Detail

LocalResolver

LocalResolver(Ref sRef,
              FlexList buf)
Makes (what should be) the one resolver for resolving sRef. sRef should start out switchable, and forwarding to a BufferingRef, for which 'buf' is the buffer.

Method Detail

resolveRace

public boolean resolveRace(Object target)
Description copied from interface: Resolver
Enabled: Queues all accumulated and future messages for delivery to target, and, for example, a local promise becomes resolved into being E-equivalent to the target.

If this resolver already Resolver.isDone(), resolveRace(..) has no effect and returns false. Otherwise, the promise (or whatever) becomes resolved, this Resolver becomes done, and resolveRace(..) returns true. In either case, a Resolver will be isDone() following a resolveRace(..).

Specified by:
resolveRace in interface Resolver
Parameters:
target -
Returns:
Whether this resolveRace(..) caused this Resolver to become done.

resolve

public void resolve(Object target)
Description copied from interface: Resolver
Enabled: Like Resolver.resolveRace(java.lang.Object), but throws an exception to report that this Resolver was already resolved, rather than returning a boolean.

Successful return indicates successful reslution.

Specified by:
resolve in interface Resolver
Parameters:
target -

smash

public boolean smash(Throwable problem)
Description copied from interface: Resolver
Enabled: Breaks the promise, reporting 'problem' as the reason.

"r.smash(p)" is equivalent to "r.resolveRace(Ref.broken(p))".

Specified by:
smash in interface Resolver
Returns:
Whether this smash(..) caused this Resolver to become done.
See Also:
Resolver.resolveRace(java.lang.Object)

isDone

public boolean isDone()
Description copied from interface: Resolver
Enabled: If not isDone(), both Resolver.resolveRace(java.lang.Object) and Resolver.smash(java.lang.Throwable) will work and return true, and Resolver.resolve(java.lang.Object) will work rather than throw an exception.

If isDone(), neither none of those will work. Once a Resolver is done, it is done forever.

Specified by:
isDone in interface Resolver

toString

public String toString()
Description copied from class: Object
Suppressed: Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.

The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:

 getClass().getName() + '@' + Integer.toHexString(hashCode())
 

Overrides:
toString in class Object
Returns:
a string representation of the object.


comments?