entitytxn.lock

A lock manager. Threads may lock values, waiting to obtain
the lock if one is already outstanding. Locks are re-entrant
and only released when fully unwound or by force.

If a lock is currently held by another thread, the current
thread may wait until the lock becomes available.

have-lock?

(have-lock? val)
Returns true if the calling thread has the lock of the specfified
value, false otherwise

lock!

(lock! val)(lock! val timeout)
Attempt to lock the given value obtaining the lock if it is available
or waiting the specified timeout in milliseconds otherwise. A timeout
of zero means unwilling to wait; negative means wait indefinitely.
Returns the value as truthy if the lock was obtained, false otherwise.

unlock!

(unlock! val)(unlock! val force)
Unlock the value. If the lock was re-entered decrement the
count unless forced, in which case unlock. When unlocking notify
a single waiter, out of any that are waiting.
Returns the value, throws if this thread is not the lock holder.