Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
/* The low-order bit of lock->Ptr is set when the lock is held. If _only_ */
/* the low-order bit is set, the lock is held in exclusive mode. */
BOOLEAN TryAcquireSRWLockExclusive(SRWLOCK* lock) {
if (sizeof lock->Ptr == sizeof LONG) {
return InterlockedBitTestAndSet((LONG*) lock->Ptr, 0);
} else if (sizeof lock->Ptr == sizeof LONG64) {
return InterlockedBitTestAndSet64((LONG64*) lock->Ptr, 0);
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.