namespace Core::CoreSpinLock
Overview
namespace CoreSpinLock { // global functions void wait(); bool tryLock(int32 volatile& lock); void lock(int32 volatile& lock); void unlock(int32 volatile& lock); } // namespace CoreSpinLock
Detailed Documentation
Global Functions
void lock(int32 volatile& lock)
Lock the spinlock.
Exponential backoff is used here to improve the worst case when multiple high priority threads are trying to acquire the same lock and the system is very busy:
Try to acquire the lock. If this fails, try to acquire the lock and wait in a loop of 10 cycles. If this fails, try to acquire the lock and wait 10 times in a loop of 1000 cycles. If this fails, yield.