public class TickerChannelsKt
Modifier and Type | Method and Description |
---|---|
static ReceiveChannel<kotlin.Unit> |
ticker(long delayMillis,
long initialDelayMillis,
NonExistentClass context,
TickerMode mode)
Creates a channel that produces the first item after the given initial delay and subsequent items with the
given delay between them.
|
public static ReceiveChannel<kotlin.Unit> ticker(long delayMillis, long initialDelayMillis, NonExistentClass context, TickerMode mode)
Creates a channel that produces the first item after the given initial delay and subsequent items with the given delay between them.
The resulting channel is a rendezvous channel. When receiver from this channel does not keep
up with receiving the elements from this channel, they are not being sent due to backpressure. The actual
timing behavior of ticker in this case is controlled by mode parameter which
is set to TickerMode.FIXED_PERIOD by default. See enum TickerMode
for other details.
This channel stops producing elements immediately after ReceiveChannel.cancel
invocation.
Note producer to this channel is dispatched via Dispatchers.getUnconfined
by default and started eagerly.
Note: Ticker channels are not currently integrated with structured concurrency and their api will change in the future.
delayMillis
- delay between each element in milliseconds.initialDelayMillis
- delay after which the first element will be produced (it is equal to delayMillis by default) in milliseconds.context
- context of the producing coroutine.mode
- specifies behavior when elements are not received (FIXED_PERIOD by default).enum TickerMode
,
ReceiveChannel.cancel
,
Dispatchers.getUnconfined