示例#1
0
 /// <summary>
 /// Attempts to set mark to the new mark if reference is equal to holding object
 /// </summary>
 /// <param name="expectedReference">Expecting reference when the mark is being applied</param>
 /// <param name="newMark">New boolean value to be set</param>
 /// <returns>True if new mark setting is successful</returns>
 public bool AttemptMark(T expectedReference, bool newMark)
 {
     if (AtomicOperationsUtilities.Compare(ref item, expectedReference))
     {
         Interlocked.Exchange(ref mark, newMark);
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#2
0
 public bool CompareAndExchange(T expectedReference, T newReference,
                                bool expectedMark, bool newMark)
 {
     return(AtomicOperationsUtilities.CompareAndSwap(ref item, expectedReference, newReference) &&
            AtomicOperationsUtilities.CompareAndSwap(ref mark, expectedMark, newMark));
 }