Class ArrayBlockingStream<T>
java.lang.Object
fr.inria.rules.integraal.util.stream.AbstractCloseableIterator<T>
fr.inria.rules.integraal.util.stream.ArrayBlockingStream<T>
- Type Parameters:
T- type of the elements
- All Implemented Interfaces:
CloseableIterator<T>, CloseableIteratorWithoutException<T>, InMemoryStream<T>, Closeable, AutoCloseable, Iterator<T>
public class ArrayBlockingStream<T>
extends AbstractCloseableIterator<T>
implements InMemoryStream<T>
Concurrent structure for read/write in a set.
- Author:
- Florent Tornil
-
Constructor Summary
ConstructorsConstructorDescriptionArrayBlockingStream(int bufferSize) Creates an array-backed blocking stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the iterator and releases its resources.booleanhasNext()Indicates whether another element is available, blocking while the stream remains open and empty.next()Returns the next element from the iterator.voidWrites every object from the supplied iterator into the in-memory stream.voidWrites one object into the stream, blocking while the buffer is full.Methods inherited from class AbstractCloseableIterator
finalizeMethods inherited from class Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Iterator
forEachRemaining, remove
-
Constructor Details
-
ArrayBlockingStream
public ArrayBlockingStream(int bufferSize) Creates an array-backed blocking stream.- Parameters:
bufferSize- size of the buffer
-
-
Method Details
-
write
Writes one object into the stream, blocking while the buffer is full.- Specified by:
writein interfaceInMemoryStream<T>- Parameters:
object- the object to write
-
hasNext
public boolean hasNext()Indicates whether another element is available, blocking while the stream remains open and empty.- Specified by:
hasNextin interfaceCloseableIterator<T>- Specified by:
hasNextin interfaceCloseableIteratorWithoutException<T>- Specified by:
hasNextin interfaceIterator<T>- Returns:
trueif another element can be read
-
next
Description copied from interface:CloseableIteratorReturns the next element from the iterator.- Specified by:
nextin interfaceCloseableIterator<T>- Specified by:
nextin interfaceCloseableIteratorWithoutException<T>- Specified by:
nextin interfaceIterator<T>- Returns:
- the next element
-
close
public void close()Description copied from interface:CloseableIteratorCloses the iterator and releases its resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceCloseableIterator<T>
-
write
Description copied from interface:InMemoryStreamWrites every object from the supplied iterator into the in-memory stream.- Specified by:
writein interfaceInMemoryStream<T>- Parameters:
it- objects to write
-