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); }
public MAtomic(MReaderWriterLock rwLock, T value) { this.rwLock = rwLock; this.ValueNoLock = value; }
public MAtomic(MReaderWriterLock rwLock) : this(rwLock, default(T)) { }
public Hoge() { rwlock = new MReaderWriterLock(); status = new MAtomic <int>(rwlock, 0); val = new MAtomic <string>(rwlock); }