SafeLock
A Lock that can be closed safely even while another thread might still be using it.
close is only really meaningful on platforms whose underlying lock frees native resources (destroying one while another thread is locking or unlocking it is undefined behavior there). Regardless of platform, close guarantees that every lock owner already holding this at the time it is called can still safely finish, and that every call to lock made after it throws IllegalStateException.
Lock is backed by java.util.concurrent.locks.ReentrantLock on the JVM and Android. There is no native resource to free, so close() there is a no-op only flipping closed.
On Linux and mingw, Lock.close() calls pthread_mutex_destroy unconditionally. That is undefined behavior while another thread is still locking or unlocking it. Stately's Lock does not check for this, which caused test failures on Linux. Apple and mingw silently ignore the same misuse.
This tracks how many lock/unlock pairs are currently in flight. It only destroys the underlying lock once none are left. The last matching unlock after close does it.
JS and wasmJs are single-threaded. There is nothing to actually lock. Only the closed check remains meaningful.
Properties
Functions
Marks this lock closed. Calling this again has no effect.
Marks this lock closed. Calling this again has no effect.
Marks this lock closed. Calling this again has no effect.
Marks this lock closed. Calling this again has no effect.