public static CachedBuffer Request(byte[] data, int offset, int size) { CachedBuffer cachedBuffer = Request(size); Buffer.BlockCopy(data, offset, cachedBuffer.Data, 0, size); return(cachedBuffer); }
public static CachedBuffer Request(byte[] data, int offset, int size) { CachedBuffer cachedBuffer = BufferPool.Request(size); Buffer.BlockCopy((Array)data, offset, (Array)cachedBuffer.Data, 0, size); return(cachedBuffer); }
public static void Recycle(CachedBuffer buffer) { int length = buffer.Length; bool flag = false; object bufferLock; try { Monitor.Enter(bufferLock = BufferPool.bufferLock, ref flag); if (length <= 32) { BufferPool.SmallBufferQueue.Enqueue(buffer); } else if (length <= 256) { BufferPool.MediumBufferQueue.Enqueue(buffer); } else { if (length > 16384) { return; } BufferPool.LargeBufferQueue.Enqueue(buffer); } } finally { if (flag) { Monitor.Exit(bufferLock); } } }
public static CachedBuffer Request(int size) { CachedBuffer cachedBuffer; lock (BufferPool.bufferLock) { if (size <= 32) { cachedBuffer = (BufferPool.SmallBufferQueue.Count != 0 ? BufferPool.SmallBufferQueue.Dequeue().Activate() : new CachedBuffer(new byte[32])); } else if (size <= 256) { cachedBuffer = (BufferPool.MediumBufferQueue.Count != 0 ? BufferPool.MediumBufferQueue.Dequeue().Activate() : new CachedBuffer(new byte[256])); } else if (size > 16384) { cachedBuffer = new CachedBuffer(new byte[size]); } else { cachedBuffer = (BufferPool.LargeBufferQueue.Count != 0 ? BufferPool.LargeBufferQueue.Dequeue().Activate() : new CachedBuffer(new byte[16384])); } } return(cachedBuffer); }
// Token: 0x06001287 RID: 4743 RVA: 0x00418074 File Offset: 0x00416274 public static CachedBuffer Request(int size) { object obj = BufferPool.bufferLock; CachedBuffer result; lock (obj) { if (size <= 32) { if (BufferPool.SmallBufferQueue.Count == 0) { result = new CachedBuffer(new byte[32]); } else { result = BufferPool.SmallBufferQueue.Dequeue().Activate(); } } else if (size <= 256) { if (BufferPool.MediumBufferQueue.Count == 0) { result = new CachedBuffer(new byte[256]); } else { result = BufferPool.MediumBufferQueue.Dequeue().Activate(); } } else if (size <= 16384) { if (BufferPool.LargeBufferQueue.Count == 0) { result = new CachedBuffer(new byte[16384]); } else { result = BufferPool.LargeBufferQueue.Dequeue().Activate(); } } else { result = new CachedBuffer(new byte[size]); } } return(result); }
public static void Recycle(CachedBuffer buffer) { int length = buffer.Length; lock (bufferLock) { if (length <= 32) SmallBufferQueue.Enqueue(buffer); else if (length <= 256) MediumBufferQueue.Enqueue(buffer); else { if (length > 16384) return; LargeBufferQueue.Enqueue(buffer); } } }
public static CachedBuffer Request(int size) { CachedBuffer result; lock (BufferPool.bufferLock) { if (size <= 32) { if (BufferPool.SmallBufferQueue.Count == 0) { result = new CachedBuffer(new byte[32]); } else { result = BufferPool.SmallBufferQueue.Dequeue().Activate(); } } else if (size <= 256) { if (BufferPool.MediumBufferQueue.Count == 0) { result = new CachedBuffer(new byte[256]); } else { result = BufferPool.MediumBufferQueue.Dequeue().Activate(); } } else if (size <= 16384) { if (BufferPool.LargeBufferQueue.Count == 0) { result = new CachedBuffer(new byte[16384]); } else { result = BufferPool.LargeBufferQueue.Dequeue().Activate(); } } else { result = new CachedBuffer(new byte[size]); } } return result; }
public static void Recycle(CachedBuffer buffer) { int length = buffer.Length; lock (BufferPool.bufferLock) { if (length <= 32) { BufferPool.SmallBufferQueue.Enqueue(buffer); } else if (length <= 256) { BufferPool.MediumBufferQueue.Enqueue(buffer); } else if (length <= 16384) { BufferPool.LargeBufferQueue.Enqueue(buffer); } } }
public static void Recycle(CachedBuffer buffer) { int length = buffer.Length; lock (bufferLock) { if (length <= 32) { SmallBufferQueue.Enqueue(buffer); } else if (length <= 256) { MediumBufferQueue.Enqueue(buffer); } else if (length <= 16384) { LargeBufferQueue.Enqueue(buffer); } } }
// Token: 0x06001289 RID: 4745 RVA: 0x00418188 File Offset: 0x00416388 public static void Recycle(CachedBuffer buffer) { int length = buffer.Length; object obj = BufferPool.bufferLock; lock (obj) { if (length <= 32) { BufferPool.SmallBufferQueue.Enqueue(buffer); } else if (length <= 256) { BufferPool.MediumBufferQueue.Enqueue(buffer); } else if (length <= 16384) { BufferPool.LargeBufferQueue.Enqueue(buffer); } } }
public static void Recycle(CachedBuffer buffer) { int length = buffer.Length; lock (BufferPool.bufferLock) { if (length <= 32) { BufferPool.SmallBufferQueue.Enqueue(buffer); } else if (length <= 256) { BufferPool.MediumBufferQueue.Enqueue(buffer); } else { if (length > 16384) { return; } BufferPool.LargeBufferQueue.Enqueue(buffer); } } }
public static CachedBuffer Request(int size) { CachedBuffer cachedBuffer; lock (BufferPool.bufferLock) { if (size <= 32) { cachedBuffer = (BufferPool.SmallBufferQueue.Count != 0 ? BufferPool.SmallBufferQueue.Dequeue().Activate() : new CachedBuffer(new byte[32])); } else if (size <= 256) { cachedBuffer = (BufferPool.MediumBufferQueue.Count != 0 ? BufferPool.MediumBufferQueue.Dequeue().Activate() : new CachedBuffer(new byte[256])); } else if (size > 16384) { cachedBuffer = new CachedBuffer(new byte[size]); } else { cachedBuffer = (BufferPool.LargeBufferQueue.Count != 0 ? BufferPool.LargeBufferQueue.Dequeue().Activate() : new CachedBuffer(new byte[16384])); } } return cachedBuffer; }
public NetPacket(ushort id, int size) { this.Id = id; this.Buffer = BufferPool.Request(size); this.Length = size; }