Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SafeHandleCache.cs
Go to the documentation of this file.
1
using
System
;
2
using
System.Runtime.InteropServices
;
3
using
System.Threading
;
4
5
namespace
Microsoft.Win32.SafeHandles
;
6
7
internal
static
class
SafeHandleCache<T> where T :
SafeHandle
8
{
9
private
static
T
s_invalidHandle
;
10
11
internal
static
T
GetInvalidHandle
(Func<T> invalidHandleFactory)
12
{
13
T val =
Volatile
.
Read
(ref
s_invalidHandle
);
14
if
(val ==
null
)
15
{
16
T val2 = invalidHandleFactory();
17
val =
Interlocked
.
CompareExchange
(ref
s_invalidHandle
, val2,
null
);
18
if
(val ==
null
)
19
{
20
GC
.
SuppressFinalize
(val2);
21
val = val2;
22
}
23
else
24
{
25
val2.Dispose();
26
}
27
}
28
return
val;
29
}
30
31
internal
static
bool
IsCachedInvalidHandle
(
SafeHandle
handle
)
32
{
33
return
handle
==
Volatile
.
Read
(ref
s_invalidHandle
);
34
}
35
}
Microsoft.Win32.SafeHandles.SafeHandleCache.GetInvalidHandle
static T GetInvalidHandle(Func< T > invalidHandleFactory)
Definition
SafeHandleCache.cs:11
Microsoft.Win32.SafeHandles.SafeHandleCache.IsCachedInvalidHandle
static bool IsCachedInvalidHandle(SafeHandle handle)
Definition
SafeHandleCache.cs:31
Microsoft.Win32.SafeHandles.SafeHandleCache.s_invalidHandle
static T s_invalidHandle
Definition
SafeHandleCache.cs:9
System.GC.SuppressFinalize
static void SuppressFinalize(object obj)
Definition
GC.cs:202
System.GC
Definition
GC.cs:8
System.Runtime.InteropServices.SafeHandle
Definition
SafeHandle.cs:7
System.Threading.Interlocked.CompareExchange
static int CompareExchange(ref int location1, int value, int comparand)
System.Threading.Interlocked
Definition
Interlocked.cs:9
System.Threading.Volatile.Read
static bool Read(ref bool location)
Definition
Volatile.cs:67
System.Threading.Volatile
Definition
Volatile.cs:9
Microsoft.Win32.SafeHandles
Definition
SafeProcessHandle.cs:3
System.Runtime.InteropServices
Definition
SequenceMarshal.cs:4
System.Threading
Definition
TaskToApm.cs:3
System.ExceptionArgument.handle
@ handle
System
Definition
BlockingCollection.cs:8
source
System.Security.Cryptography.Csp
Microsoft.Win32.SafeHandles
SafeHandleCache.cs
Generated by
1.10.0