TryAcquireSRWLockShared
TryAcquireSRWLockShared attempts to acquire the SRW lock in shared mode.
Syntax
BOOL TryAcquireSRWLockShared(
PSRWLOCK pSrwLock
);
Parameters
pSrwLock
A pointer to the SRW lock to acquire.
Return Value
Returns TRUE if the lock was successfully acquired, FALSE otherwise.
Remarks
- This function does not block if the lock cannot be acquired.
- This function returns FALSE if the lock is held in any mode.
- This function succeed if the lock is already held in shared mode or is unowned.
- This function increments the shared reference count on success.
- This function raises EXCEPTION_ACCESS_VIOLATION if pSrwLock is NULL.
Requirements
| Minimum supported version | Header | Library |
|---|---|---|
|
wRTOS 1.1 SDK |
windows.h |
wRTOS_rtss.lib |
Example
if (TryAcquireSRWLockShared(&lock)) {
// Successfully acquired
// Perform read operations
ReleaseSRWLockShared(&lock);
} else {
// Lock was busy with exclusive access
}
See Also: