tornadofx / tornadofx / Latch

Latch

class Latch : CountDownLatch

Adds some superpowers to good old CountDownLatch, like exposed lockedProperty or ability to release latch immediately.

By default, initializes a latch with a count of 1, which means that the first invocation of countDown will allow all waiting threads to proceed.

All documentation of superclass applies here. Default behavior has not been altered.

Constructors

<init> Latch(count: Int = 1)

Adds some superpowers to good old CountDownLatch, like exposed lockedProperty or ability to release latch immediately.

Properties

locked val locked: <ERROR CLASS>

Locked state of this latch. true if and only if CountDownLatch.getCount is greater than 0. Once latch is released it changes to false permanently.

Functions

countDown fun countDown(): Unit
lockedProperty fun lockedProperty(): ReadOnlyBooleanProperty

Locked state of this latch exposed as a property. Keep in mind that latch instance can be used only once, so this property has to rebound every time.

release fun release(): <ERROR CLASS>

Releases latch immediately and allows waiting thread(s) to proceed. Can be safely used if this latch has been initialized with count of 1, should be used with care otherwise - countDown invocations ar preferred in such cases.

Extension Functions

getProperty fun <T> Any.getProperty(prop: KMutableProperty1<*, T>): ObjectProperty<T>
observable fun <T : Any> Any.observable(propName: String): ObjectProperty<T>