Package com.gengoai.concurrent
Class Broker.Builder<V>
- java.lang.Object
-
- com.gengoai.concurrent.Broker.Builder<V>
-
-
Constructor Summary
Constructors Constructor Description Builder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Broker.Builder<V>
addConsumer(Consumer<? super V> consumer)
Adds a consumer.Broker.Builder<V>
addConsumer(Consumer<? super V> consumer, int number)
Adds a consumer and will run it on a number of threads.Broker.Builder<V>
addConsumers(Collection<? extends Consumer<? super V>> consumers)
Add a collection of consumers.Broker.Builder<V>
addProducer(Broker.Producer<V> producer)
Adds a producerBroker.Builder<V>
addProducer(Broker.Producer<V> producer, int number)
Adds producer and sets it to run on a number of threads.Broker.Builder<V>
addProducers(Collection<? extends Broker.Producer<V>> producers)
Adds a collection of producers.Broker.Builder<V>
bufferSize(int size)
The size of the buffer.Broker<V>
build()
Builds A Broker.
-
-
-
Method Detail
-
addConsumer
public Broker.Builder<V> addConsumer(Consumer<? super V> consumer)
Adds a consumer.- Parameters:
consumer
- the consumer- Returns:
- the builder
-
addConsumer
public Broker.Builder<V> addConsumer(Consumer<? super V> consumer, int number)
Adds a consumer and will run it on a number of threads.- Parameters:
consumer
- the consumernumber
- the number of threads to run the consumer on.- Returns:
- the builder
-
addConsumers
public Broker.Builder<V> addConsumers(Collection<? extends Consumer<? super V>> consumers)
Add a collection of consumers.- Parameters:
consumers
- the consumers- Returns:
- the builder
-
addProducer
public Broker.Builder<V> addProducer(Broker.Producer<V> producer, int number)
Adds producer and sets it to run on a number of threads. Note that the producer must be thread safe.- Parameters:
producer
- the producernumber
- the number of threads to run the producer on.- Returns:
- the builder
-
addProducer
public Broker.Builder<V> addProducer(Broker.Producer<V> producer)
Adds a producer- Parameters:
producer
- the producer- Returns:
- the builder
-
addProducers
public Broker.Builder<V> addProducers(Collection<? extends Broker.Producer<V>> producers)
Adds a collection of producers.- Parameters:
producers
- the producers- Returns:
- the builder
-
bufferSize
public Broker.Builder<V> bufferSize(int size)
The size of the buffer.- Parameters:
size
- the size- Returns:
- the builder
-
-