Module org.refcodes.generator
Package org.refcodes.generator
Class ThreadLocalBufferedGeneratorDecorator<T>
java.lang.Object
org.refcodes.generator.ThreadLocalBufferedGeneratorDecorator<T>
- Type Parameters:
T
- the generic type of the elements being generated.
- All Implemented Interfaces:
Iterator<T>
,BufferedGenerator<T>
,Generator<T>
,org.refcodes.mixin.DecorateeAccessor<Iterator<T>>
,org.refcodes.mixin.Disposable
,org.refcodes.mixin.Suspendable
public class ThreadLocalBufferedGeneratorDecorator<T>
extends Object
implements BufferedGenerator<T>, org.refcodes.mixin.DecorateeAccessor<Iterator<T>>, org.refcodes.mixin.Disposable
The
ThreadLocalBufferedGeneratorDecorator
decorates a
Generator
with read-ahead functionality by buffering generated IDs on
a per Thread
basis: The resulting Generator
is thread safe!.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.refcodes.mixin.DecorateeAccessor
org.refcodes.mixin.DecorateeAccessor.DecorateeBuilder<DECORATEE extends Object,
B extends org.refcodes.mixin.DecorateeAccessor.DecorateeBuilder<DECORATEE, B>>, org.refcodes.mixin.DecorateeAccessor.DecorateeMutator<DECORATEE extends Object>, org.refcodes.mixin.DecorateeAccessor.DecorateeProperty<DECORATEE extends Object> -
Field Summary
-
Constructor Summary
ConstructorDescriptionThreadLocalBufferedGeneratorDecorator
(Iterator<T> aDecoratee) Constructs theThreadLocalBufferedGeneratorDecorator
decorating the providedGenerator
using theDEFAULT_BUFFER_SIZE
for the per thread read-ahead buffer.ThreadLocalBufferedGeneratorDecorator
(Iterator<T> aDecoratee, int aBufferSize) Constructs theThreadLocalBufferedGeneratorDecorator
decorating the providedGenerator
. -
Method Summary
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
-
Constructor Details
-
ThreadLocalBufferedGeneratorDecorator
Constructs theThreadLocalBufferedGeneratorDecorator
decorating the providedGenerator
using theDEFAULT_BUFFER_SIZE
for the per thread read-ahead buffer.- Parameters:
aDecoratee
- TheGenerator
to be decorated.
-
ThreadLocalBufferedGeneratorDecorator
Constructs theThreadLocalBufferedGeneratorDecorator
decorating the providedGenerator
.- Parameters:
aDecoratee
- TheGenerator
to be decorated.aBufferSize
- The size of the read-ahead buffer
-
-
Method Details
-
hasNext
public boolean hasNext()Tests whether theGenerator
is capable of generating aGenerator.next()
item. -
next
Generates a next item. -
remove
public void remove() -
suspend
public void suspend()- Specified by:
suspend
in interfaceorg.refcodes.mixin.Suspendable
-
getDecoratee
- Specified by:
getDecoratee
in interfaceorg.refcodes.mixin.DecorateeAccessor<T>
-
dispose
public void dispose()- Specified by:
dispose
in interfaceorg.refcodes.mixin.Disposable
-