コード例 #1
0
        public virtual void TestGroupIteratorConcurrency()
        {
            Counters counters = new Counters();

            counters.IncrCounter("group1", "counter1", 1);
            Counters.Group group = counters.GetGroup("group1");
            IEnumerator <Counters.Counter> iterator = group.GetEnumerator();

            counters.IncrCounter("group1", "counter2", 1);
            iterator.Next();
        }
コード例 #2
0
        public virtual void TestFileSystemGroupIteratorConcurrency()
        {
            Counters counters = new Counters();

            // create 2 filesystem counter groups
            counters.FindCounter("fs1", FileSystemCounter.BytesRead).Increment(1);
            counters.FindCounter("fs2", FileSystemCounter.BytesRead).Increment(1);
            // Iterate over the counters in this group while updating counters in
            // the group
            Counters.Group group = counters.GetGroup(typeof(FileSystemCounter).FullName);
            IEnumerator <Counters.Counter> iterator = group.GetEnumerator();

            counters.FindCounter("fs3", FileSystemCounter.BytesRead).Increment(1);
            NUnit.Framework.Assert.IsTrue(iterator.HasNext());
            iterator.Next();
            counters.FindCounter("fs3", FileSystemCounter.BytesRead).Increment(1);
            NUnit.Framework.Assert.IsTrue(iterator.HasNext());
            iterator.Next();
        }