Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
PinnedObject.cs
Go to the documentation of this file.
1
using
System.Runtime.InteropServices
;
2
using
System.Threading
;
3
4
namespace
System.Reflection.Internal
;
5
6
internal
sealed
class
PinnedObject
:
CriticalDisposableObject
7
{
8
private
GCHandle
_handle
;
9
10
private
int
_isValid
;
11
12
public
unsafe
byte
*
Pointer
=> (
byte
*)(
void
*)
_handle
.
AddrOfPinnedObject
();
13
14
public
PinnedObject
(
object
obj
)
15
{
16
_handle
=
GCHandle
.
Alloc
(
obj
,
GCHandleType
.Pinned);
17
_isValid
= 1;
18
}
19
20
protected
override
void
Release
()
21
{
22
try
23
{
24
}
25
finally
26
{
27
if
(
Interlocked
.
Exchange
(ref
_isValid
, 0) != 0)
28
{
29
_handle
.
Free
();
30
}
31
}
32
}
33
}
System.Reflection.Internal.CriticalDisposableObject
Definition
CriticalDisposableObject.cs:6
System.Reflection.Internal.PinnedObject.Release
override void Release()
Definition
PinnedObject.cs:20
System.Reflection.Internal.PinnedObject.PinnedObject
PinnedObject(object obj)
Definition
PinnedObject.cs:14
System.Reflection.Internal.PinnedObject._handle
GCHandle _handle
Definition
PinnedObject.cs:8
System.Reflection.Internal.PinnedObject._isValid
int _isValid
Definition
PinnedObject.cs:10
System.Reflection.Internal.PinnedObject
Definition
PinnedObject.cs:7
System.Reflection.Pointer
Definition
Pointer.cs:8
System.Threading.Interlocked.Exchange
static int Exchange(ref int location1, int value)
System.Threading.Interlocked
Definition
Interlocked.cs:9
System.Reflection.Internal
Definition
AbstractMemoryBlock.cs:4
System.Runtime.InteropServices.GCHandleType
GCHandleType
Definition
GCHandleType.cs:4
System.Runtime.InteropServices
Definition
SequenceMarshal.cs:4
System.Threading
Definition
TaskToApm.cs:3
System.ExceptionArgument.obj
@ obj
System.Runtime.InteropServices.GCHandle.Free
void Free()
Definition
GCHandle.cs:91
System.Runtime.InteropServices.GCHandle.AddrOfPinnedObject
unsafe IntPtr AddrOfPinnedObject()
Definition
GCHandle.cs:98
System.Runtime.InteropServices.GCHandle.Alloc
static GCHandle Alloc(object? value)
Definition
GCHandle.cs:81
System.Runtime.InteropServices.GCHandle
Definition
GCHandle.cs:9
source
System.Reflection.Metadata
System.Reflection.Internal
PinnedObject.cs
Generated by
1.10.0