5 // Marek Safar (marek.safar@gmail.com)
7 // Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
9 // Permission is hereby granted, free of charge, to any person obtaining a copy
10 // of this software and associated documentation files (the "Software"), to deal
11 // in the Software without restriction, including without limitation the rights
12 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 // copies of the Software, and to permit persons to whom the Software is
14 // furnished to do so, subject to the following conditions:
16 // The above copyright notice and this permission notice shall be included in
17 // all copies or substantial portions of the Software.
19 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 using System.Runtime.ConstrainedExecution;
30 using System.Runtime.CompilerServices;
32 namespace System.Threading
34 public static class Volatile
36 [MethodImplAttribute (MethodImplOptions.InternalCall)]
37 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
38 public extern static bool Read (ref bool location);
40 [MethodImplAttribute (MethodImplOptions.InternalCall)]
41 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
42 public extern static byte Read (ref byte location);
44 [MethodImplAttribute (MethodImplOptions.InternalCall)]
45 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
46 [CLSCompliant (false)]
47 public extern static sbyte Read (ref sbyte location);
49 [MethodImplAttribute (MethodImplOptions.InternalCall)]
50 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
51 public extern static short Read (ref short location);
53 [MethodImplAttribute (MethodImplOptions.InternalCall)]
54 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
55 [CLSCompliant (false)]
56 public extern static ushort Read (ref ushort location);
58 [MethodImplAttribute (MethodImplOptions.InternalCall)]
59 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
60 public extern static int Read (ref int location);
62 [MethodImplAttribute (MethodImplOptions.InternalCall)]
63 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
64 [CLSCompliant (false)]
65 public extern static uint Read (ref uint location);
67 [MethodImplAttribute (MethodImplOptions.InternalCall)]
68 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
69 public extern static long Read (ref long location);
71 [MethodImplAttribute (MethodImplOptions.InternalCall)]
72 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
73 [CLSCompliant (false)]
74 public extern static ulong Read (ref ulong location);
76 [MethodImplAttribute (MethodImplOptions.InternalCall)]
77 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
78 public extern static IntPtr Read (ref IntPtr location);
80 [MethodImplAttribute (MethodImplOptions.InternalCall)]
81 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
82 [CLSCompliant (false)]
83 public extern static UIntPtr Read (ref UIntPtr location);
85 [MethodImplAttribute (MethodImplOptions.InternalCall)]
86 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
87 public extern static double Read (ref double location);
89 [MethodImplAttribute (MethodImplOptions.InternalCall)]
90 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
91 public extern static float Read (ref float location);
93 [MethodImplAttribute (MethodImplOptions.InternalCall)]
94 public extern static T Read<T> (ref T location) where T : class;
96 [MethodImplAttribute (MethodImplOptions.InternalCall)]
97 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
98 public extern static void Write (ref bool location, bool value);
100 [MethodImplAttribute (MethodImplOptions.InternalCall)]
101 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
102 public extern static void Write (ref byte location, byte value);
104 [MethodImplAttribute (MethodImplOptions.InternalCall)]
105 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
106 [CLSCompliant (false)]
107 public extern static void Write (ref sbyte location, sbyte value);
109 [MethodImplAttribute (MethodImplOptions.InternalCall)]
110 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
111 public extern static void Write (ref short location, short value);
113 [MethodImplAttribute (MethodImplOptions.InternalCall)]
114 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
115 [CLSCompliant (false)]
116 public extern static void Write (ref ushort location, ushort value);
118 [MethodImplAttribute (MethodImplOptions.InternalCall)]
119 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
120 public extern static void Write (ref int location, int value);
122 [MethodImplAttribute (MethodImplOptions.InternalCall)]
123 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
124 [CLSCompliant (false)]
125 public extern static void Write (ref uint location, uint value);
127 [MethodImplAttribute (MethodImplOptions.InternalCall)]
128 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
129 public extern static void Write (ref long location, long value);
131 [MethodImplAttribute (MethodImplOptions.InternalCall)]
132 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
133 [CLSCompliant (false)]
134 public extern static void Write (ref ulong location, ulong value);
136 [MethodImplAttribute (MethodImplOptions.InternalCall)]
137 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
138 public extern static void Write (ref IntPtr location, IntPtr value);
140 [MethodImplAttribute (MethodImplOptions.InternalCall)]
141 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
142 [CLSCompliant (false)]
143 public extern static void Write (ref UIntPtr location, UIntPtr value);
145 [MethodImplAttribute (MethodImplOptions.InternalCall)]
146 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
147 public extern static void Write (ref double location, double value);
149 [MethodImplAttribute (MethodImplOptions.InternalCall)]
150 [ReliabilityContract (Consistency.WillNotCorruptState, Cer.Success)]
151 public extern static void Write (ref float location, float value);
153 [MethodImplAttribute (MethodImplOptions.InternalCall)]
154 public extern static void Write<T>(ref T location, T value) where T : class;