ReentrantLock

expect class ReentrantLock : Lock

Port of java.util.concurrent.locks.ReentrantLock.

Use platform-specific actual implementations so JVM code can rely on the real JDK lock semantics while native continues using the shared coroutine-backed port.

Constructors

Link copied to clipboard
expect constructor()

Functions

Link copied to clipboard
Link copied to clipboard
expect open override fun lock()

Acquires the lock.

Link copied to clipboard
expect open override fun lockInterruptibly()

Acquires the lock unless the current thread is interrupted.

Link copied to clipboard
expect open override fun newCondition(): Condition

Returns a new Condition instance that is bound to this Lock instance.

Link copied to clipboard
expect open override fun tryLock(): Boolean

Acquires the lock only if it is free at the time of invocation.

expect open override fun tryLock(time: Long, unit: TimeUnit): Boolean

Acquires the lock if it is free within the given waiting time and the current thread has not been interrupted.

Link copied to clipboard
expect open override fun unlock()

Releases the lock.

Link copied to clipboard
inline fun <T> ReentrantLock.withLock(action: () -> T): T