コード例 #1
0
ファイル: Interlocked.cs プロジェクト: spaceflint7/bluebonnet
        //
        // Int32
        //

        public static int CompareExchange(system.Int32 data, int update, int expect)
        {
            int current = data.VolatileGet();

            data.CompareAndSwap(expect, update);
            return(current);
        }
コード例 #2
0
ファイル: Interlocked.cs プロジェクト: spaceflint7/bluebonnet
 public static int Exchange(system.Int32 data, int update)
 {
     for (;;)
     {
         int current = data.VolatileGet();
         if (data.CompareAndSwap(current, update))
         {
             return(current);
         }
     }
 }
コード例 #3
0
ファイル: Interlocked.cs プロジェクト: spaceflint7/bluebonnet
 public static int Add(system.Int32 data, int v)
 {
     for (;;)
     {
         int current = data.VolatileGet();
         int next    = current + v;
         if (data.CompareAndSwap(current, next))
         {
             return(next);
         }
     }
 }
コード例 #4
0
ファイル: Interlocked.cs プロジェクト: spaceflint7/bluebonnet
 public static int Decrement(system.Int32 data)
 {
     for (;;)
     {
         int current = data.VolatileGet();
         int next    = current - 1;
         if (data.CompareAndSwap(current, next))
         {
             return(next);
         }
     }
 }