public static byte[] TakeBufferAndReturn(this ClearHelper ch, int bufferSize) { var result = ObjectPool.Default.TakeBuffer(bufferSize); if (null != result) { ch.Push(c => ObjectPool.Default.ReturnBuffer((byte[])c), result); } return(result); }
public static T TakeObjectAndReturn <T>(this ClearHelper ch) where T : class { var result = ObjectPool.TakeObject <T>(); if (null != result) { ch.Push(c => ObjectPool.ReturnObject <object>(c), result); } return(result); }