コード例 #1
0
 public virtual void TestClear()
 {
     NUnit.Framework.Assert.IsFalse(set.IsEmpty());
     NUnit.Framework.Assert.AreEqual(3, set.Count);
     set.Clear();
     NUnit.Framework.Assert.IsTrue(set.IsEmpty());
     NUnit.Framework.Assert.AreEqual(0, set.Count);
 }
コード例 #2
0
        public bool ThreadWaiting(int waitingOnThreadId, object lockObject)
        {
            _waitingThreadIds.Add(RunningThreadId);
            if (_waitingThreadIds.NumElems == NumUnfinishedThreads)
            {
                _threadIdsSeenWhileAllWaiting.Add(RunningThreadId);
            }
            else
            {
                _threadIdsSeenWhileAllWaiting.Clear();
            }
            bool deadlock   = NumUnfinishedThreads == 1 || _threadIdsSeenWhileAllWaiting.NumElems == NumUnfinishedThreads;
            int  originalId = RunningThreadId;

            if (!deadlock)
            {
                while (RunningThreadId == originalId)
                {
                    MaybeSwitch();
                }
            }
            return(deadlock);
        }