Class ThrottledAccumulatingConsumer
- java.lang.Object
-
- com.google.cloud.tools.jib.event.progress.ThrottledAccumulatingConsumer
-
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,java.util.function.Consumer<java.lang.Long>
public class ThrottledAccumulatingConsumer extends java.lang.Object implements java.util.function.Consumer<java.lang.Long>, java.io.Closeable
Wraps aConsumer<Long>
so that multiple consume calls (accept(java.lang.Long)
) within a short period of time are merged into a single later call with the value accumulated up to that point.
-
-
Constructor Summary
Constructors Constructor Description ThrottledAccumulatingConsumer(java.util.function.Consumer<java.lang.Long> callback)
Wraps a consumer with the delay of 100 ms.ThrottledAccumulatingConsumer(java.util.function.Consumer<java.lang.Long> consumer, java.time.Duration delayBetweenCallbacks, java.util.function.Supplier<java.time.Instant> getNow)
A new configured consumer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(java.lang.Long value)
void
close()
-
-
-
Constructor Detail
-
ThrottledAccumulatingConsumer
public ThrottledAccumulatingConsumer(java.util.function.Consumer<java.lang.Long> callback)
Wraps a consumer with the delay of 100 ms.- Parameters:
callback
-Consumer
callback to wrap
-
ThrottledAccumulatingConsumer
public ThrottledAccumulatingConsumer(java.util.function.Consumer<java.lang.Long> consumer, java.time.Duration delayBetweenCallbacks, java.util.function.Supplier<java.time.Instant> getNow)
A new configured consumer.- Parameters:
consumer
-Consumer
callback to wrapdelayBetweenCallbacks
- delay between each call to the underlying acceptgetNow
- supplies of the current timeInstant
-
-