Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
InterlockedBitVector32.cs
Go to the documentation of this file.
3
5
6internal struct InterlockedBitVector32
7{
8 private int _data;
9
10 public bool this[int bit]
11 {
12 get
13 {
14 return (Volatile.Read(ref _data) & bit) == bit;
15 }
16 set
17 {
18 if (value)
19 {
20 Interlocked.Or(ref _data, bit);
21 }
22 else
23 {
24 Interlocked.And(ref _data, ~bit);
25 }
26 }
27 }
28
29 public void DangerousSet(int bit, bool value)
30 {
31 _data = (value ? (_data | bit) : (_data & ~bit));
32 }
33
34 public static int CreateMask()
35 {
36 return CreateMask(0);
37 }
38
39 public static int CreateMask(int previous)
40 {
41 if (previous != 0)
42 {
43 return previous << 1;
44 }
45 return 1;
46 }
47
48 public override bool Equals([NotNullWhen(true)] object o)
49 {
50 if (o is InterlockedBitVector32 interlockedBitVector)
51 {
52 return _data == interlockedBitVector._data;
53 }
54 return false;
55 }
56
57 public override int GetHashCode()
58 {
59 return base.GetHashCode();
60 }
61}
static int And(ref int location1, int value)
static int Or(ref int location1, int value)
static bool Read(ref bool location)
Definition Volatile.cs:67
override bool Equals([NotNullWhen(true)] object o)