/// <summary> /// 将buffer放回缓冲池中回收等待利用 /// </summary> /// <param name="buffer"></param> public void RecycleBuffer(AsyncUserDataBuffer buffer) { // 缓冲池已满时销毁该对象 if (!_bufferPool.Push(buffer)) { buffer.Dispose(); } }
/// <summary> /// 销毁消息体所占用的资源 /// </summary> public void Dispose() { if (null != Data) { Data.Buffer = null; Data.IP = null; Data = null; } }
/// <summary> /// 实例化一个用户数据消息体并指定数据内容 /// </summary> /// <param name="data"></param> public AsyncUserDataEvent(AsyncUserDataBuffer data) { Data = data; }
/// <summary> /// 实例化一个用户数据消息体 /// </summary> public AsyncUserDataEvent() { Data = null; }