Package discord4j.common
Class ResettableInterval
- java.lang.Object
-
- discord4j.common.ResettableInterval
-
- All Implemented Interfaces:
Sinks.EmitFailureHandler
public class ResettableInterval extends Object implements Sinks.EmitFailureHandler
Emit ticks at a constant rate specified atstart(Duration, Duration)and will continue untilstop()is called orstart(Duration, Duration)is re-invoked, resetting the previous emitter. The ticks are available from theticks()method.
-
-
Field Summary
-
Fields inherited from interface reactor.core.publisher.Sinks.EmitFailureHandler
FAIL_FAST
-
-
Constructor Summary
Constructors Constructor Description ResettableInterval(Scheduler scheduler)Create aResettableIntervalthat emits ticks on the givenSchedulerupon callingstart(Duration, Duration).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanonEmitFailure(SignalType signalType, Sinks.EmitResult result)voidstart(Duration delay, Duration period)Begin producing ticks at the given rate.voidstop()Dispose the current emitter task without completing or cancelling existing subscriptions toticks().Flux<Long>ticks()Return aFluxthat emits ticks at the currently configured rate.
-
-
-
Constructor Detail
-
ResettableInterval
public ResettableInterval(Scheduler scheduler)
Create aResettableIntervalthat emits ticks on the givenSchedulerupon callingstart(Duration, Duration).- Parameters:
scheduler- the ReactorSchedulerto use to emit ticks
-
-
Method Detail
-
start
public void start(Duration delay, Duration period)
Begin producing ticks at the given rate.- Parameters:
delay- theDurationto wait before emitting the first tickperiod- the periodDurationused to emit ticks.- See Also:
Flux.interval(Duration, Duration, Scheduler)
-
stop
public void stop()
Dispose the current emitter task without completing or cancelling existing subscriptions toticks().
-
ticks
public Flux<Long> ticks()
Return aFluxthat emits ticks at the currently configured rate.- Returns:
- a
Fluxof increasing values since the laststart(Duration, Duration)call
-
onEmitFailure
public boolean onEmitFailure(SignalType signalType, Sinks.EmitResult result)
- Specified by:
onEmitFailurein interfaceSinks.EmitFailureHandler
-
-