/
InterlockedImpl.cs
72 lines (71 loc) · 1.92 KB
/
InterlockedImpl.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using System;
using System.Threading;
using IL2CPU.API.Attribs;
namespace Cosmos.Core_Plugs.System.Threading
{
[Plug(Target = typeof(Interlocked))]
public static class InterlockedImpl
{
public static int Decrement(ref int aData)
{
return aData -= 1;
}
public static long Decrement(ref long aData)
{
return aData -= 1;
}
public static int Increment(ref int aData)
{
return aData += 1;
}
public static long Increment(ref long aData)
{
return aData += 1;
}
public static int Exchange(ref int loc1, int aData)
{
int orgValue = loc1;
loc1 = aData;
return orgValue;
}
public static long Exchange(ref long loc1, long aData)
{
long orgValue = loc1;
loc1 = aData;
return orgValue;
}
public static float Exchange(ref float loc1, float aData)
{
float orgValue = loc1;
loc1 = aData;
return orgValue;
}
public static double Exchange(ref double loc1, double aData)
{
double orgValue = loc1;
loc1 = aData;
return orgValue;
}
public static Object Exchange(ref Object loc1, Object aData)
{
Object orgValue = loc1;
loc1 = aData;
return orgValue;
}
public static IntPtr Exchange(ref IntPtr loc1, IntPtr aData)
{
IntPtr orgValue = loc1;
loc1 = aData;
return orgValue;
}
public static EventHandler CompareExchange(ref EventHandler loc1, EventHandler val, EventHandler comparand)
{
EventHandler old = loc1;
if (loc1 == comparand)
{
loc1 = val;
}
return old;
}
}
}