본문 바로가기

Kotlin/10. Channel

10.4 Ticker Channel

Ticker Channel

public fun ticker(
    delayMillis: Long,
    initialDelayMillis: Long = delayMillis,
    context: CoroutineContext = EmptyCoroutineContext,
    mode: TickerMode = TickerMode.FIXED_PERIOD
): ReceiveChannel<Unit>
  • 인자로 주어진 시간마다 Channel로 Unit 값을 send
  • Ticker는 RENDEZVOUS(랑데뷰) Channel
    • 버퍼사이즈가 0 인 Channel
    • Send 호출은 Receive 하기 전에 일시 중단
    • Receive 도 Send 하기 전에는 일시 중단
  • Ticker Mode
    • TickerMode.FIXED_PERIOD
      • 채널 지연이 생겨도 주어진 delay time 에 무조건 방출(Default Mode)
    • TickerMode.FIXED_DELAY
      • 지연이 생기면 지연된 시간 후 delay time 에 방출

'Kotlin > 10. Channel' 카테고리의 다른 글

10.3 Channel Pipelines / Fan-In, Fan-Out  (0) 2023.11.01
10.2 Buffered Channel  (0) 2023.11.01
10.1 Channel이란  (1) 2023.11.01
10. Channel  (0) 2023.11.01