Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
VirtualHeap.cs
Go to the documentation of this file.
5
7
8internal sealed class VirtualHeap : CriticalDisposableObject
9{
10 private struct PinnedBlob
11 {
13
14 public readonly int Length;
15
17 {
18 Handle = handle;
19 Length = length;
20 }
21
23 {
24 return new MemoryBlock((byte*)(void*)Handle.AddrOfPinnedObject(), Length);
25 }
26 }
27
29
30 private VirtualHeap()
31 {
33 }
34
35 protected override void Release()
36 {
38 if (dictionary == null)
39 {
40 return;
41 }
43 {
44 item.Value.Handle.Free();
45 }
46 }
47
49 {
51 if (blobs == null)
52 {
53 throw new ObjectDisposedException("VirtualHeap");
54 }
55 return blobs;
56 }
57
59 {
60 if (!GetBlobs().TryGetValue(rawHandle, out var value))
61 {
62 block = default(MemoryBlock);
63 return false;
64 }
65 block = value.GetMemoryBlock();
66 return true;
67 }
68
69 internal MemoryBlock AddBlob(uint rawHandle, byte[] value)
70 {
74 return value2.GetMemoryBlock();
75 }
76
78 {
79 if (lazyHeap == null)
80 {
82 }
83 return lazyHeap;
84 }
85}
void Add(TKey key, TValue value)
MemoryBlock AddBlob(uint rawHandle, byte[] value)
bool TryGetMemoryBlock(uint rawHandle, out MemoryBlock block)
Dictionary< uint, PinnedBlob > _blobs
static VirtualHeap GetOrCreateVirtualHeap(ref VirtualHeap? lazyHeap)
Dictionary< uint, PinnedBlob > GetBlobs()
static int CompareExchange(ref int location1, int value, int comparand)
static int Exchange(ref int location1, int value)
static GCHandle Alloc(object? value)
Definition GCHandle.cs:81