Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CachedBuffer.cs
Go to the documentation of this file.
1using System.IO;
2
4
5public class CachedBuffer
6{
7 public readonly byte[] Data;
8
9 public readonly BinaryWriter Writer;
10
11 public readonly BinaryReader Reader;
12
13 private readonly MemoryStream _memoryStream;
14
15 private bool _isActive = true;
16
17 public int Length => Data.Length;
18
19 public bool IsActive => _isActive;
20
21 public CachedBuffer(byte[] data)
22 {
23 Data = data;
24 _memoryStream = new MemoryStream(data);
25 Writer = new BinaryWriter(_memoryStream);
26 Reader = new BinaryReader(_memoryStream);
27 }
28
30 {
31 _isActive = true;
32 _memoryStream.Position = 0L;
33 return this;
34 }
35
36 public void Recycle()
37 {
38 if (_isActive)
39 {
40 _isActive = false;
41 BufferPool.Recycle(this);
42 }
43 }
44}
static void Recycle(CachedBuffer buffer)
Definition BufferPool.cs:61
readonly MemoryStream _memoryStream