TryAcquireSRWLockExclusive
TryAcquireSRWLockExclusive attempts to acquire the SRW lock in exclusive mode.
Syntax
BOOL TryAcquireSRWLockExclusive(
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 returns TRUE only if the lock was unowned and is now owned exclusively.
- This function does not raise EXCEPTION_ACCESS_VIOLATION if pSrwLock is NULL. Instead, it returns FALSE.
Requirements
| Minimum supported version | Header | Library |
|---|---|---|
|
wRTOS 1.1 SDK |
windows.h |
wRTOS_rtss.lib |
Example
if (TryAcquireSRWLockExclusive(&lock)) {
// Successfully acquired
// Perform operations
ReleaseSRWLockExclusive(&lock);
} else {
// Lock was busy, handle appropriately
}
See Also: