Package org.ojalgo.type.function
Interface AutoConsumer<T>
- All Superinterfaces:
AutoCloseable
,AutoFunctional
,Consumer<T>
- All Known Subinterfaces:
ScoredDualConsumer<T>
,ToFileWriter<T>
- All Known Implementing Classes:
DataWriter
,ManagedConsumer
,MappedConsumer
,QueuedConsumer
,ShardedConsumer
,ShardedConsumer.GeneralShardedConsumer
,ShardedConsumer.PowerOf2ShardedConsumer
,TextLineWriter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface
public interface AutoConsumer<T>
extends AutoCloseable, Consumer<T>, AutoFunctional
Utilities for
AutoCloseable
Consumer
:s-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault void
default void
close()
static <T> AutoConsumer
<T> Will create a JMX bean, with the given name, that keeps track of the consumer's throughput.static <T> AutoConsumer
<T> managed
(Throughput manager, Consumer<T> consumer) If you want that throughput manager to be registered as a JMX bean, that's up to you.static <S,
T> AutoConsumer <S> Map/transform and then consumestatic <T> AutoConsumer
<T> queued
(ExecutorService executor, BlockingQueue<T> queue, Consumer<T>... consumers) Put on the queue, and then the consumers work off that queue.static <T> AutoConsumer
<T> sharded
(ToIntFunction<T> distributor, Consumer<T>... consumers) Distribute to 1 of the consumersvoid
Write the item to the consumer.default void
writeBatch
(Iterable<? extends T> batch) Write the batch (collection of items) to the consumer.
-
Field Details
-
NULL
-
-
Method Details
-
managed
Will create a JMX bean, with the given name, that keeps track of the consumer's throughput. -
managed
If you want that throughput manager to be registered as a JMX bean, that's up to you. -
mapped
Map/transform and then consume -
queued
static <T> AutoConsumer<T> queued(ExecutorService executor, BlockingQueue<T> queue, Consumer<T>... consumers) Put on the queue, and then the consumers work off that queue. There will be 1 thread (executor task) per consumer. -
sharded
Distribute to 1 of the consumers -
accept
-
close
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
write
Write the item to the consumer.- Parameters:
item
- The item to be written
-
writeBatch
Write the batch (collection of items) to the consumer.- Parameters:
batch
- The batch to be written
-