Package com.gengoai.concurrent
Class Broker.Producer<V>
- java.lang.Object
-
- com.gengoai.concurrent.Broker.Producer<V>
-
- Direct Known Subclasses:
IterableProducer
,StreamProducer
public abstract static class Broker.Producer<V> extends Object
A producer generates data to be consumed. Implementations of Producer should use the
start()
to begin the production process,stop()
to signal production has finished, andyield(Object)
to offer an item up for consumption.
-
-
Constructor Summary
Constructors Constructor Description Producer()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description boolean
isRunning()
abstract void
produce()
Logic for producing items to be consumed.protected void
start()
Signals the production has started.protected void
stop()
Signals that the producer is finished and its thread can be released.protected void
yield(V object)
offers an object to be consumed, blocking if the Broker's queue is full.
-
-
-
Method Detail
-
isRunning
public boolean isRunning()
- Returns:
- True if the producer is still running.
-
produce
public abstract void produce()
Logic for producing items to be consumed.
-
start
protected void start()
Signals the production has started.
-
stop
protected void stop()
Signals that the producer is finished and its thread can be released.
-
yield
protected final void yield(V object)
offers an object to be consumed, blocking if the Broker's queue is full.- Parameters:
object
- the object
-
-