void CBufferPool::PutFreeBuffer(TBuffer* pBuffer) { if(pBuffer->IsValid()) { BOOL bOK = FALSE; { CCriSecLock locallock(pBuffer->cs); if(pBuffer->IsValid()) { pBuffer->Reset(); bOK = TRUE; } } if(bOK) { m_itPool.PutFreeItem(pBuffer->items); { CCriSecLock locallock(m_csFreeBuffer); m_lsFreeBuffer.PushBack(pBuffer); } if((DWORD)m_lsFreeBuffer.Size() > m_dwBufferPoolHold) CompressFreeBuffer(m_dwBufferPoolSize); } } }
void CIocpServer::AddFreeBufferObj(TBufferObj* pBufferObj) { CCriSecLock locallock(m_csFreeBuffer); m_lsFreeBuffer.push_back(pBufferObj); if(m_lsFreeBuffer.size() > m_dwFreeBufferObjHold) CompressFreeBuffer(m_dwFreeBufferObjPool); }
void CTcpAgent::AddFreeBufferObj(TBufferObj* pBufferObj) { if(m_lsFreeBuffer.size() < m_dwFreeBufferObjHold) { CCriSecLock locallock(m_csFreeBuffer); m_lsFreeBuffer.push_back(pBufferObj); } else { DeleteBufferObj(pBufferObj); CompressFreeBuffer(m_dwFreeBufferObjPool); } }
void CUdpServer::AddFreeBufferObj(TUdpBufferObj* pBufferObj) { // ~ 灵异事件 ~ // 32 位 Release 版本:当客户端连上服务器时会导致服务器崩溃 /* if(m_lsFreeBuffer.size() < m_dwFreeBufferObjHold) { CCriSecLock locallock(m_csFreeBuffer); m_lsFreeBuffer.push_back(pBufferObj); } else { DeleteBufferObj(pBufferObj); CompressFreeBuffer(m_dwFreeBufferObjPool); } */ #if defined(_DEBUG) || defined(_WIN64) if(m_lsFreeBuffer.size() < m_dwFreeBufferObjHold) { CCriSecLock locallock(m_csFreeBuffer); m_lsFreeBuffer.push_back(pBufferObj); } else { DeleteBufferObj(pBufferObj); CompressFreeBuffer(m_dwFreeBufferObjPool); } #else { CCriSecLock locallock(m_csFreeBuffer); m_lsFreeBuffer.push_back(pBufferObj); } if(m_lsFreeBuffer.size() > m_dwFreeBufferObjHold) CompressFreeBuffer(m_dwFreeBufferObjPool); #endif }
void CTcpAgent::ReleaseFreeBuffer() { CompressFreeBuffer(0); }
void CTcpServer::ReleaseFreeBuffer() { CompressFreeBuffer(0); }