public static void FinalizeReaderWriterLock(this OsState os, ref ReaderWriterLockType rwLock) { Assert.True(rwLock.LockState == ReaderWriterLockType.State.Initialized); // Don't allow finalizing a locked lock. Assert.True(ReaderWriterLockImpl.GetReadLockCount(in ReaderWriterLockImpl.GetLockCount(ref rwLock)) == 0); Assert.True(ReaderWriterLockImpl.GetWriteLocked(in ReaderWriterLockImpl.GetLockCount(ref rwLock)) == 0); // Mark not initialized. rwLock.LockState = ReaderWriterLockType.State.NotInitialized; // Destroy objects. ReaderWriterLockImpl.GetLockCount(ref rwLock).Cs.FinalizeObject(); }
public static void InitializeReaderWriterLock(this OsState os, ref ReaderWriterLockType rwLock) { // Create objects. ReaderWriterLockImpl.GetLockCount(ref rwLock).Cs.Initialize(); rwLock.CvReadLockWaiter.Initialize(); rwLock.CvWriteLockWaiter.Initialize(); // Set member variables. ReaderWriterLockImpl.ClearReadLockCount(ref ReaderWriterLockImpl.GetLockCount(ref rwLock)); ReaderWriterLockImpl.ClearWriteLocked(ref ReaderWriterLockImpl.GetLockCount(ref rwLock)); ReaderWriterLockImpl.ClearReadLockWaiterCount(ref ReaderWriterLockImpl.GetLockCount(ref rwLock)); ReaderWriterLockImpl.ClearWriteLockWaiterCount(ref ReaderWriterLockImpl.GetLockCount(ref rwLock)); ReaderWriterLockImpl.ClearWriteLockCount(ref rwLock); rwLock.OwnerThread = 0; // Mark initialized. rwLock.LockState = ReaderWriterLockType.State.Initialized; }
internal OsStateImpl(OsState parent) => Os = parent;
public static bool IsReadLockHeld(this OsState os, in ReaderWriterLockType rwLock)
public static void ReleaseWriteLock(this OsState os, ref ReaderWriterLockType rwLock) { Assert.True(rwLock.LockState == ReaderWriterLockType.State.Initialized); os.Impl.ReleaseWriteLockImpl(ref rwLock); }
public static bool TryAcquireWriteLock(this OsState os, ref ReaderWriterLockType rwLock) { Assert.True(rwLock.LockState == ReaderWriterLockType.State.Initialized); return(os.Impl.TryAcquireWriteLockImpl(ref rwLock)); }
public static void SleepThread(this OsState os, TimeSpan time) { TimeoutHelperImpl.Sleep(os, time); }
public static void AcquireWriteLock(this OsState os, ref ReaderWriterLockType rwLock) { Assert.SdkRequires(rwLock.LockState == ReaderWriterLockType.State.Initialized); os.Impl.AcquireWriteLockImpl(ref rwLock); }