Ejemplo n.º 1
0
        public static object CompareExchange(system.Reference data, object update, object expect)
        {
            // the real CompareExchange takes a 'ref object' first parameter,
            // but we take system.Reference so we can access its CompareAndSwap method.
            // this depends on CilMethod::IsInterlockedOrVolatile() -- see there.
            object current = data.VolatileGet();

            data.CompareAndSwap(expect, update);
            return(current);
        }
Ejemplo n.º 2
0
 public static object Exchange(system.Reference data, object update)
 {
     for (;;)
     {
         object current = data.VolatileGet();
         if (data.CompareAndSwap(current, update))
         {
             return(current);
         }
     }
 }