Ejemplo n.º 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();
        }
Ejemplo n.º 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;
        }