public void MReaderWriterLock_LockTest()
        {
            var rwlock = new MReaderWriterLock();
            var val    = 0;

            var presult = Parallel.ForEach(Enumerable.Range(0, 100), i =>
            {
                using var wlock = rwlock.GetWriterLock();

                ++val;
            });

            while (!presult.IsCompleted)
            {
                Thread.Sleep(1);
            }

            Assert.AreEqual(100, val);
        }
Пример #2
0
 public MAtomic(MReaderWriterLock rwLock, T value)
 {
     this.rwLock      = rwLock;
     this.ValueNoLock = value;
 }
Пример #3
0
 public MAtomic(MReaderWriterLock rwLock) : this(rwLock, default(T))
 {
 }
Пример #4
0
 public Hoge()
 {
     rwlock = new MReaderWriterLock();
     status = new MAtomic <int>(rwlock, 0);
     val    = new MAtomic <string>(rwlock);
 }