Smart RWLocker
Composite mutex which works with next rules:
acquireRead require to writeMutex be free. Then it will take one lock from readSemaphore
releaseRead will just free up one permit in readSemaphore
lockWrite will lock writeMutex and then await while all readSemaphore will be freed
unlockWrite will just unlock writeMutex
Functions
Do lock in readSemaphore inside of writeMutex locking
Locking writeMutex and wait while all readSemaphore permits will be freed
Release one read permit in readSemaphore
Unlock writeMutex
Will wait until the SmartSemaphore.permitsStateFlow of this instance will have permits count free permits.
Will wait until the SmartMutex.lockStateFlow of this instance will be false.
Will call SmartSemaphore.Mutable.lock, then execute action and return the result after SmartSemaphore.Mutable.unlock
Will call SmartMutex.Mutable.lock, then execute action and return the result after SmartMutex.Mutable.unlock