VerboseCountDownLatch

A CountDownLatch that logs a message on each wait timeout and retries until the latch reaches zero.

Useful for long-running waits where periodic logging is desired to indicate the system is still waiting.

Parameters

count

the number of times countDown must be invoked before threads can pass through await.

Constructors

Link copied to clipboard
constructor(count: Int)

Properties

Link copied to clipboard
open val count: Long
Link copied to clipboard

Whether this CountDownLatch has reached zero.

Functions

Link copied to clipboard
fun await(timeout: Duration, msg: () -> Any?)

The verbose await with a message lambda, for Java callers; see the java.time.Duration await taking a String.

fun await(timeout: Duration, msg: String)

The verbose await for Java callers: the overloads taking a Kotlin Duration are compiled under a mangled name that Java cannot call.

fun await(timeout: Duration, msg: () -> Any?)

Waits repeatedly for the latch to reach zero, logging the result of msg at INFO level each time the timeout expires without the latch being satisfied.

fun await(timeout: Duration, msg: String)

Waits repeatedly for the latch to reach zero, logging msg at INFO level each time the timeout expires without the latch being satisfied.

open fun await()
open fun await(timeout: Long, unit: TimeUnit?): Boolean
Link copied to clipboard

Waits for the CountDownLatch to reach zero, or for the specified duration to elapse.

Link copied to clipboard
open fun countDown()
Link copied to clipboard
fun CountDownLatch.countDown(block: () -> Unit)

Executes block and calls CountDownLatch.countDown in a finally block, ensuring the latch is decremented even if the block throws.

Link copied to clipboard
open fun toString(): String