Terraria v1.4.4.9
Terraria source code documentation
All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events Macros

◆ TryCreateMemoryMappedFileBlock()

bool System.Reflection.Internal.StreamMemoryBlockProvider.TryCreateMemoryMappedFileBlock ( long start,
int size,
[NotNullWhen(true)] out MemoryMappedFileBlock block )
inlineprivate

Definition at line 97 of file StreamMemoryBlockProvider.cs.

98 {
99 if (_lazyMemoryMap == null)
100 {
101 IDisposable disposable;
102 lock (_streamGuard)
103 {
104 disposable = MemoryMapLightUp.CreateMemoryMap(_stream);
105 }
106 if (disposable == null)
107 {
108 block = null;
109 return false;
110 }
111 if (Interlocked.CompareExchange(ref _lazyMemoryMap, disposable, null) != null)
112 {
113 disposable.Dispose();
114 }
115 }
116 IDisposable disposable2 = MemoryMapLightUp.CreateViewAccessor(_lazyMemoryMap, start, size);
117 if (disposable2 == null)
118 {
119 block = null;
120 return false;
121 }
122 if (!MemoryMapLightUp.TryGetSafeBufferAndPointerOffset(disposable2, out SafeBuffer safeBuffer, out long offset))
123 {
124 block = null;
125 return false;
126 }
127 block = new MemoryMappedFileBlock(disposable2, safeBuffer, offset, size);
128 return true;
129 }
static int CompareExchange(ref int location1, int value, int comparand)

References System.Reflection.Internal.StreamMemoryBlockProvider._lazyMemoryMap, System.Reflection.Internal.StreamMemoryBlockProvider._stream, System.Reflection.Internal.StreamMemoryBlockProvider._streamGuard, System.Threading.Interlocked.CompareExchange(), System.Reflection.Internal.MemoryMapLightUp.CreateMemoryMap(), System.Reflection.Internal.MemoryMapLightUp.CreateViewAccessor(), System.IDisposable.Dispose(), System.offset, System.start, and System.Reflection.Internal.MemoryMapLightUp.TryGetSafeBufferAndPointerOffset().

Referenced by System.Reflection.Internal.StreamMemoryBlockProvider.GetMemoryBlockImpl().