public UnsafeLock(SpinLock *spinLock) { this.spinLock = spinLock; this.lockTaken = false; spinLock->Enter(ref this.lockTaken); }
public unsafe void Test_ArrayExtensions_Pointer() { SpinLock spinLock = default; SpinLock *p = &spinLock; int sum = 0; Parallel.For(0, 1000, i => { for (int j = 0; j < 10; j++) { using (SpinLockExtensions.Enter(p)) { sum++; } } }); Assert.AreEqual(sum, 1000 * 10); }
public static unsafe UnsafeLock Enter(SpinLock *spinLock) { return(new(spinLock)); }