forked from Unity-Technologies/com.unity.netcode.gameobjects
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPooledBitStream.cs
More file actions
34 lines (32 loc) · 962 Bytes
/
Copy pathPooledBitStream.cs
File metadata and controls
34 lines (32 loc) · 962 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
using System;
namespace MLAPI.Serialization.Pooled
{
/// <summary>
/// Disposable BitStream that returns the Stream to the BitStreamPool when disposed
/// </summary>
public sealed class PooledBitStream : BitStream, IDisposable
{
private bool isDisposed = false;
/// <summary>
/// Gets a PooledBitStream from the static BitStreamPool
/// </summary>
/// <returns>PooledBitStream</returns>
public static PooledBitStream Get()
{
PooledBitStream stream = BitStreamPool.GetStream();
stream.isDisposed = false;
return stream;
}
/// <summary>
/// Returns the PooledBitStream into the static BitStreamPool
/// </summary>
public new void Dispose()
{
if (!isDisposed)
{
isDisposed = true;
BitStreamPool.PutBackInPool(this);
}
}
}
}