BooleanMonitor

A GenericMonitor implementation backed by an atomic boolean value.

Threads can block until the value becomes true or false using the inherited waitUntilTrue and waitUntilFalse methods from GenericMonitor.

Parameters

initValue

the initial boolean value.

Constructors

Link copied to clipboard
constructor(initValue: Boolean)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override val monitorSatisfied: Boolean

Whether the monitor's condition is currently satisfied. Implemented by subclasses.

Functions

Link copied to clipboard
fun get(): Boolean

Returns the current boolean value.

Link copied to clipboard
fun set(value: Boolean)

Sets the boolean value in a thread-safe manner, entering and leaving the monitor.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun waitUntil(value: Boolean)

Blocks indefinitely until the condition matches value.

fun waitUntil(value: Boolean, waitTime: Duration): Boolean

Blocks until the condition matches value or the timeout expires.

Link copied to clipboard

Blocks the current thread until monitorSatisfied returns false. This method is not interruptible.

Blocks the current thread until monitorSatisfied returns false or the timeout expires. This method is not interruptible.

Repeatedly waits for the condition to become false, invoking block on each timeout.

fun waitUntilFalse(timeout: Duration, maxWait: Duration, block: MonitorAction?): Boolean

Repeatedly waits for the condition to become false, invoking block on each timeout, up to an overall maximum wait duration.

Link copied to clipboard

Blocks the current thread until monitorSatisfied returns true. This method is not interruptible.

Blocks the current thread until monitorSatisfied returns true or the timeout expires. This method is not interruptible.

Repeatedly waits for the condition to become true, invoking block on each timeout.

fun waitUntilTrue(timeout: Duration, maxWait: Duration, block: MonitorAction?): Boolean

Repeatedly waits for the condition to become true, invoking block on each timeout, up to an overall maximum wait duration.

Link copied to clipboard

Blocks the current thread until monitorSatisfied returns true. This method can be interrupted.

Blocks the current thread until monitorSatisfied returns true or the timeout expires. This method can be interrupted.

Repeatedly waits (interruptibly) for the condition to become true, invoking block on each timeout.

Repeatedly waits (interruptibly) for the condition to become true, invoking block on each timeout, up to an overall maximum wait duration.