/* Wait for spin lock */ static INLINE LONG slwait (volatile LONG *sl) { while (interlockedexchange (sl, 1) != 0) #ifndef FX_SMPBUILD // Faster not to sleep on multiprocessor machines Sleep (0) #endif ; return 0; }
// in newer compilers, the inline versions of these are used (in beast_atomic.h), but in // older ones we have to actually call the ops as win32 functions.. long beast_interlockedexchange (volatile long* a, long b) noexcept { return interlockedexchange (a, b); }
/* Release spin lock */ static INLINE LONG slrelease (volatile LONG *sl) { interlockedexchange (sl, 0); return 0; }
/* Try waiting for spin lock */ static INLINE LONG sltrywait (volatile LONG *sl) { return (interlockedexchange (sl, 1) != 0); }