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.waterken.serial; 004 005 import org.ref_send.promise.Promise; 006 007 /** 008 * An infinite series of elements. 009 * <p> 010 * A series is a FIFO list of values where the values can be removed from the 011 * list before they have been added. An invocation of {@link #consume} returns 012 * a promise for what will be the next element in the list, once it is added, at 013 * which time it will already have been removed. ;) 014 * </p> 015 * @param <T> value type 016 */ 017 public interface 018 Series<T> extends Iterable<Promise<T>> { 019 020 /** 021 * Gets the front element. 022 */ 023 Element<T> getFront(); 024 025 /** 026 * Appends a value to the end of the series. 027 * @param value value to append 028 */ 029 void produce(Promise<T> value); 030 031 /** 032 * Removes the first element in the series. 033 * @return value of the removed element 034 */ 035 Promise<T> consume(); 036 }