public unsafe void CouldAcquireEnterExitReleaseExclusiveLock() { var ptr = (long *)Marshal.AllocHGlobal(8); * ptr = 0; var wpid = Wpid.Create(); var wpid2 = Wpid.Create(); var sl = new SharedSpinLock(ptr); Assert.AreEqual(Wpid.Empty, sl.TryAcquireExclusiveLock(wpid, out var tt, spinLimit: 0)); Assert.AreEqual(Wpid.Empty, sl.TryReEnterExclusiveLock(wpid, tt, spinLimit: 0)); Assert.Throws <InvalidOperationException>(() => { sl.TryReleaseLock(wpid); }); Assert.AreEqual(Wpid.Empty, sl.TryExitExclusiveLock(wpid, tt)); Assert.AreEqual(Wpid.Empty, sl.TryReleaseLock(wpid)); }
public Wpid TryExitExclusiveLock(Wpid wpid, byte threadToken) { return(SharedSpinLock.TryExitExclusiveLock(ref *(long *)(_statePointer + StreamLogStateRecord.LockerOffset), wpid, threadToken)); }