예제 #1
0
 public void Add(int v)
 {
     while (true)
     {
         var local = Volatile.Read(ref _data);
         var copy  = new CyclicArray(local); // Assume an initial parent thread creates this instance (so no null check on _data)
         copy.Add(v);
         if (Interlocked.CompareExchange(ref _data, copy, local) == local)
         {
             break;
         }
     }
 }
예제 #2
0
 public RWLockList(int capacity)
 {
     _data = new CyclicArray(capacity);
 }
예제 #3
0
 public MultipleWriterCOWList(int capacity)
 {
     _data = new CyclicArray(capacity);
 }