示例#1
0
        public static void run()
        {
            L2List list = (L2List)db.Root;

            for (int i = 0; i < nIterations; i++)
            {
                long sum = 0, n = 0;
                list.SharedLock();
                L2Elem head = list.head;
                L2Elem elem = head;
                do
                {
                    elem.Load();
                    sum += elem.count;
                    n   += 1;
                } while ((elem = elem.next) != head);
                Tests.Assert(n == nElements && sum == (long)nElements * (nElements - 1) / 2);
                list.Unlock();
                list.ExclusiveLock();
                L2Elem last = list.head.prev;
                last.unlink();
                last.linkAfter(list.head);
                list.Unlock();
            }
        }
示例#2
0
    public static void run()
    {
        L2List list = (L2List)db.Root;

        for (int i = 0; i < nIterations; i++)
        {
            long sum = 0, n = 0;
            list.SharedLock();
            L2Elem head = list.head;
            L2Elem elem = head;
            do
            {
                elem.Load();
                sum += elem.count;
                n   += 1;
            } while ((elem = elem.next) != head);
            Debug.Assert(n == nElements && sum == (long)nElements * (nElements - 1) / 2);
            list.Unlock();
            list.ExclusiveLock();
            L2Elem last = list.head.prev;
            last.unlink();
            last.linkAfter(list.head);
            list.Unlock();
        }
#if COMPACT_NET_FRAMEWORK
        lock (typeof(TestConcur))
        {
            if (++nFinishedThreads == nThreads)
            {
                db.Close();
            }
        }
#endif
    }
 static void RotateList(L2List list)
 {
     using (ExclusiveLock xl = new ExclusiveLock(list))
     {
         L2Elem last = list.head.prev;
         last.unlink();
         last.linkAfter(list.head);
     }
 }