public static Segment Get(int size) { lock (msSegmentPool) { if (msSegmentPool.Count > 0) { var seg = msSegmentPool.Pop(); seg.data = ByteBuffer.Allocate(size, true); return(seg); } } return(new Segment(size)); }
private Segment(int size) { data = ByteBuffer.Allocate(size, true); }