Пример #1
0
        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();
        }
Пример #2
0
        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;
        }
Пример #3
0
 internal OsStateImpl(OsState parent) => Os = parent;
Пример #4
0
 public static bool IsReadLockHeld(this OsState os, in ReaderWriterLockType rwLock)
Пример #5
0
 public static void ReleaseWriteLock(this OsState os, ref ReaderWriterLockType rwLock)
 {
     Assert.True(rwLock.LockState == ReaderWriterLockType.State.Initialized);
     os.Impl.ReleaseWriteLockImpl(ref rwLock);
 }
Пример #6
0
 public static bool TryAcquireWriteLock(this OsState os, ref ReaderWriterLockType rwLock)
 {
     Assert.True(rwLock.LockState == ReaderWriterLockType.State.Initialized);
     return(os.Impl.TryAcquireWriteLockImpl(ref rwLock));
 }
Пример #7
0
 public static void SleepThread(this OsState os, TimeSpan time)
 {
     TimeoutHelperImpl.Sleep(os, time);
 }
Пример #8
0
 public static void AcquireWriteLock(this OsState os, ref ReaderWriterLockType rwLock)
 {
     Assert.SdkRequires(rwLock.LockState == ReaderWriterLockType.State.Initialized);
     os.Impl.AcquireWriteLockImpl(ref rwLock);
 }