// // Int32 // public static int CompareExchange(system.Int32 data, int update, int expect) { int current = data.VolatileGet(); data.CompareAndSwap(expect, update); return(current); }
public static int Exchange(system.Int32 data, int update) { for (;;) { int current = data.VolatileGet(); if (data.CompareAndSwap(current, update)) { return(current); } } }
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); } } }
public static int Decrement(system.Int32 data) { for (;;) { int current = data.VolatileGet(); int next = current - 1; if (data.CompareAndSwap(current, next)) { return(next); } } }
static void Main(string[] args) { // Region 1 /* * double y = 15.75; * */ int i = 13.75; system.Int32 y = 15.3256; bool e = new bool(12.3); // Region 2 byte valy = 1_2_9; Console.WriteLine(); short j = 12_98_5; Console.WriteLine(); int x = 54_776; Console.WriteLine(); long v = 99_432; Console.WriteLine(); float on = 004_443; Console.WriteLine(); double down = 99954_004; Console.WriteLine(); decimal g = 00033_443; Console.WriteLine(); //Region 3 Max Min Values byte a = 12; Console.WriteLine("byte\tA = {0}\t{1}\t{2}\t{3}", a, typeof(byte), byte.MaxValue, byte.MinValue); }