Exemplo n.º 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();
            }
        }
Exemplo n.º 2
0
        public void Run(TestConfig config)
        {
            int count = config.Count;
            var res   = new TestConcurResult();

            config.Result = res;

            TestConcur.nElements = count;
            var start = DateTime.Now;

            db = config.GetDatabase();
            L2List list = (L2List)db.Root;

            Tests.Assert(list == null);
            list           = new L2List();
            list.head      = new L2Elem();
            list.head.next = list.head.prev = list.head;
            db.Root        = list;
            for (int i = 1; i < nElements; i++)
            {
                L2Elem elem = new L2Elem();
                elem.count = i;
                elem.linkAfter(list.head);
            }
            res.InsertTime = DateTime.Now - start;

            start = DateTime.Now;
            Thread[] threads = new Thread[nThreads];
            for (int i = 0; i < nThreads; i++)
            {
                threads[i] = new Thread(new ThreadStart(run));
                threads[i].Start();
            }
            for (int i = 0; i < nThreads; i++)
            {
                threads[i].Join();
            }
            db.Close();
            res.AccessTime = DateTime.Now - start;
        }
Exemplo n.º 3
0
 internal L2ListEnumerator(L2List <T> list)
 {
     this.list = list;
     Reset();
 }