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.Volatile;
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 */
016 public interface
017 Series<T> extends Iterable<Volatile<T>> {
018
019 /**
020 * Appends a value to the end of the series.
021 * @param value value to append
022 */
023 void
024 produce(Volatile<T> value);
025
026 /**
027 * Removes the first element in the series.
028 * @return value of the removed element
029 */
030 Volatile<T>
031 consume();
032 }