// Write an item to the pipe. Don't flush it yet. If incomplete is // set to true the item is assumed to be continued by items // subsequently written to the pipe. Incomplete items are never // flushed down the stream. public final void write(final T value_, boolean incomplete_) { // Place the value to the queue, add new terminator element. queue.push(value_); // Move the "flush up to here" poiter. if (!incomplete_) { f = queue.back_pos(); } }
// Pop an incomplete item from the pipe. Returns true is such // item exists, false otherwise. public T unwrite() { if (f == queue.back_pos()) return null; queue.unpush(); return queue.back(); }
public YPipe(int qsize) { queue = new YQueue<T>(qsize); w = r = f = queue.back_pos(); c = new AtomicInteger(queue.back_pos()); }