001 // Copyright 2007 Waterken Inc. under the terms of the MIT X license
002 // found at http://www.opensource.org/licenses/mit-license.html
003 package org.ref_send.promise;
004
005 /**
006 * A {@link Promise} resolver.
007 * @param <T> promised referent type
008 */
009 public interface
010 Resolver<T> extends Receiver<T> {
011
012 /**
013 * Logs progress towards resolution.
014 */
015 void progress();
016
017 /**
018 * Put the corresponding promise in the rejected state.
019 * <p>
020 * This method is syntactic sugar for:
021 * </p>
022 * <pre>
023 * {@link #resolve resolve}({@link Eventual#reject reject}(reason));
024 * </pre>
025 * @param reason reason the corresponding promise will not be fulfilled
026 */
027 void reject(Exception reason);
028
029 /**
030 * Resolve the corresponding promise to the given promise.
031 * @param promise promise to forward requests to
032 */
033 void resolve(Promise<? extends T> promise);
034
035 /**
036 * Resolve the corresponding promise to the given reference.
037 * @param referent reference to forward requests to
038 */
039 void apply(T referent);
040 }