Exemplo n.º 1
0
 /// <summary>
 /// Atomically exchanges two values.
 /// </summary>
 public static void Exchange <T>(ref T location1, ref T location2)
 {
     if (UnsafeTools.SizeOf(TypeOf <T> .TypeID) > IntPtr.Size)
     {
         throw new ArgumentException("Value is longer than native reference size.");
     }
     _Exchange(__makeref(location1), __makeref(location2));
 }
Exemplo n.º 2
0
        public static byte[] MemorySerialize <T>(T?value) where T : struct
        {
            Type t    = TypeOf <T?> .TypeID;
            int  size = UnsafeTools.SizeOf(t);

            byte[] arr = new byte[size];
            Copier <T?> .Copy(arr, value);

            return(arr);
        }
Exemplo n.º 3
0
 public static void Exchange(TypedReference location1, TypedReference location2)
 {
     if (__reftype(location1) != __reftype(location2))
     {
         throw new ArgumentException("Reference types do not match.");
     }
     if (UnsafeTools.SizeOf(__reftype(location1)) > IntPtr.Size)
     {
         throw new ArgumentException("Value is longer than native reference size.");
     }
     _Exchange(location1, location2);
 }