file
SharedLock.hCnxSharedLock
provides a shared-ownership scoped mutex locking mechanism similar to C++'s std::shared_lock
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Classes
- struct CnxSharedLock
CnxSharedLock
provides scoped non-exclusive (shared) locking of higher-level mutexes (egCnxSharedMutex
,CnxSharedTimedMutex
) provided by Cnx. It allows for a simple, concise way to acquire the shared lock on a mutex and ensure that lock is released appropriately when theCnxSharedLock
exits scope.
Typedefs
- using CnxSharedLock = struct CnxSharedLock
CnxSharedLock
provides scoped non-exclusive (shared) locking of higher-level mutexes (egCnxSharedMutex
,CnxSharedTimedMutex
) provided by Cnx. It allows for a simple, concise way to acquire the shared lock on a mutex and ensure that lock is released appropriately when theCnxSharedLock
exits scope.
Functions
- void cnx_shared_lock_lock(CnxSharedLock*restrict lock)
- Acquires a shared lock on the mutex associated with the given
CnxSharedLock
- bool cnx_shared_lock_try_lock(CnxSharedLock*restrict lock)
- Attempts to acquire a shared lock on the mutex associated with the given
CnxSharedLock
- bool cnx_shared_lock_try_lock_for(CnxSharedLock*restrict lock, CnxDuration duration)
- Attempts to acquire a shared lock on the mutex associated with the given
CnxSharedLock
- bool cnx_shared_lock_try_lock_until(CnxSharedLock*restrict lock, CnxTimePoint stop_point)
- Attempts to acquire a shared lock on the mutex associated with the given
CnxSharedLock
- void cnx_shared_lock_unlock(CnxSharedLock*restrict lock)
- Unlocks the mutex associated with the given
CnxSharedLock
- CnxSharedMutexInterface cnx_shared_lock_mutex(CnxSharedLock*restrict lock)
- Returns the
CnxSharedMutexInterface
Trait object corresponding with the mutex associated with the givenCnxSharedLock
- bool cnx_shared_lock_owns_lock(CnxSharedLock*restrict lock)
- Returns whether the given
CnxSharedLock
currently owns a non-exclusive (shared) lock on its associated mutex. - void cnx_shared_lock_free(void* lock)
- Destroys the given
CnxSharedLock
, unlocking its associated mutex if it owns a lock on it.
Defines
- #define SharedLock
- Declaring a
CnxSharedLock
as aSharedLock
ensures that it will be destroyed when it exits scope, releasing the lock on its associated mutex. - #define cnx_shared_lock(...)
- Creates a new
CnxSharedLock
associated with the given mutex.