Package discord4j.common
Class ResettableInterval
- java.lang.Object
-
- discord4j.common.ResettableInterval
-
public class ResettableInterval extends Object
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.
-
-
Constructor Summary
Constructors Constructor Description ResettableInterval(Scheduler scheduler)
Create aResettableInterval
that emits ticks on the givenScheduler
upon callingstart(Duration, Duration)
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
start(Duration delay, Duration period)
Begin producing ticks at the given rate.void
stop()
Dispose the current emitter task without completing or cancelling existing subscriptions toticks()
.Flux<Long>
ticks()
Return aFlux
that emits ticks at the currently configured rate.
-
-
-
Constructor Detail
-
ResettableInterval
public ResettableInterval(Scheduler scheduler)
Create aResettableInterval
that emits ticks on the givenScheduler
upon callingstart(Duration, Duration)
.- Parameters:
scheduler
- the ReactorScheduler
to use to emit ticks
-
-
Method Detail
-
start
public void start(Duration delay, Duration period)
Begin producing ticks at the given rate.- Parameters:
delay
- theDuration
to wait before emitting the first tickperiod
- the periodDuration
used 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 aFlux
that emits ticks at the currently configured rate.- Returns:
- a
Flux
of increasing values since the laststart(Duration, Duration)
call
-
-