withLock

abstract suspend fun <T> withLock(id: UUID, block: suspend () -> T): LockResult<T>

Acquires a lock for a specific entity and executes a block of code.

Return

The result of the lock operation.

Parameters

T

The type of the result.

id

The unique identifier of the entity to lock.

block

The block of code to execute while holding the lock.