Mirror Networking
Mirror.NetworkReaderPool Class Reference

Pool of NetworkReaders to avoid allocations. More...

Static Public Member Functions

static NetworkReaderPooled GetReader (byte[] bytes)
 
static NetworkReaderPooled Get (byte[] bytes)
 Get the next reader in the pool. If pool is empty, creates a new Reader More...
 
static NetworkReaderPooled GetReader (ArraySegment< byte > segment)
 
static NetworkReaderPooled Get (ArraySegment< byte > segment)
 Get the next reader in the pool. If pool is empty, creates a new Reader More...
 
static void Recycle (NetworkReaderPooled reader)
 
static void Return (NetworkReaderPooled reader)
 Returns a reader to the pool. More...
 

Detailed Description

Pool of NetworkReaders to avoid allocations.

Definition at line 8 of file NetworkReaderPool.cs.

Member Function Documentation

◆ Get() [1/2]

static NetworkReaderPooled Mirror.NetworkReaderPool.Get ( ArraySegment< byte >  segment)
static

Get the next reader in the pool. If pool is empty, creates a new Reader

Definition at line 40 of file NetworkReaderPool.cs.

41 {
42 // grab from pool & set buffer
43 NetworkReaderPooled reader = Pool.Get();
44 reader.SetBuffer(segment);
45 return reader;
46 }

◆ Get() [2/2]

static NetworkReaderPooled Mirror.NetworkReaderPool.Get ( byte[]  bytes)
static

Get the next reader in the pool. If pool is empty, creates a new Reader

Definition at line 26 of file NetworkReaderPool.cs.

27 {
28 // grab from pool & set buffer
29 NetworkReaderPooled reader = Pool.Get();
30 reader.SetBuffer(bytes);
31 return reader;
32 }

◆ Return()

static void Mirror.NetworkReaderPool.Return ( NetworkReaderPooled  reader)
static

Returns a reader to the pool.

Definition at line 54 of file NetworkReaderPool.cs.

55 {
56 Pool.Return(reader);
57 }