Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MemoryMappedFileBlock.cs
Go to the documentation of this file.
3
5
7{
9 {
11
13
14 private unsafe byte* _pointer;
15
16 public unsafe byte* Pointer => _pointer;
17
18 public unsafe DisposableData(IDisposable accessor, SafeBuffer safeBuffer, long offset)
19 {
20 byte* pointer = null;
21 safeBuffer.AcquirePointer(ref pointer);
22 _accessor = accessor;
23 _safeBuffer = safeBuffer;
25 }
26
27 protected unsafe override void Release()
28 {
29 Interlocked.Exchange(ref _safeBuffer, null)?.ReleasePointer();
30 Interlocked.Exchange(ref _accessor, null)?.Dispose();
31 _pointer = null;
32 }
33 }
34
35 private readonly DisposableData _data;
36
37 private readonly int _size;
38
39 public unsafe override byte* Pointer => _data.Pointer;
40
41 public override int Size => _size;
42
43 internal MemoryMappedFileBlock(IDisposable accessor, SafeBuffer safeBuffer, long offset, int size)
44 {
45 _data = new DisposableData(accessor, safeBuffer, offset);
46 _size = size;
47 }
48
49 public override void Dispose()
50 {
51 _data.Dispose();
52 }
53}
unsafe DisposableData(IDisposable accessor, SafeBuffer safeBuffer, long offset)
MemoryMappedFileBlock(IDisposable accessor, SafeBuffer safeBuffer, long offset, int size)
unsafe void AcquirePointer(ref byte *pointer)
Definition SafeBuffer.cs:58
static int Exchange(ref int location1, int value)