コード例 #1
0
 /// <summary>
 /// Add a <see cref="Sequence"/> into this aggregate.
 /// </summary>
 /// <param name="sequence">sequence to be added to the aggregate.</param>
 public void Add(Sequence sequence)
 {
     Sequence[] oldSequences;
     Sequence[] newSequences;
     do
     {
         oldSequences = _sequencesRef.ReadFullFence();
         int oldSize = oldSequences.Length;
         newSequences = new Sequence[oldSize + 1];
         Array.Copy(oldSequences, newSequences, oldSize);
         newSequences[oldSize] = sequence;
     }while (!_sequencesRef.AtomicCompareExchange(newSequences, oldSequences));
 }
コード例 #2
0
 public void AtomicCompareExchangeReturnsTrueIfComparandEqualsCurrentValue()
 {
     Assert.IsTrue(_volatile.AtomicCompareExchange(_newValue, _initialValue));
 }