public void TestTinyLock_Lock() { var tl = new HalfLock(); const int count = 100000000; Stopwatch sw = new Stopwatch(); sw.Start(); for (int x = 0; x < count; x++) { using (tl.Lock()) ; using (tl.Lock()) ; using (tl.Lock()) ; using (tl.Lock()) ; using (tl.Lock()) ; using (tl.Lock()) ; using (tl.Lock()) ; using (tl.Lock()) ; using (tl.Lock()) ; using (tl.Lock()) ; } sw.Stop(); Console.WriteLine((count * 10.0 / sw.Elapsed.TotalSeconds / 1000000)); }
internal HalfLockRelease(HalfLock halfLock) { if (halfLock is null) { throw new ArgumentNullException("halfLock"); } if (halfLock.m_release.m_halfLock != null) { throw new Exception("Object is already locked"); } m_halfLock = halfLock; }
internal HalfLockRelease(HalfLock halfLock) { if ((object)halfLock == null) throw new ArgumentNullException("halfLock"); if (halfLock.m_release.m_halfLock != null) throw new Exception("Object is already locked"); m_halfLock = halfLock; }