本文整理汇总了C++中TItem类的典型用法代码示例。如果您正苦于以下问题:C++ TItem类的具体用法?C++ TItem怎么用?C++ TItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TItem类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locallock
int CUdpCast::SendInternal(const BYTE* pBuffer, int iLength)
{
int result = NO_ERROR;
if(HasStarted())
{
CCriSecLock locallock(m_csSend);
if(HasStarted())
{
ASSERT(m_iPending >= 0);
BOOL isPending = m_iPending > 0;
TItem* pItem = m_itPool.PickFreeItem();
pItem->Cat(pBuffer, iLength);
m_lsSend.PushBack(pItem);
m_iPending += iLength;
if(!isPending) m_evBuffer.Set();
}
else
result = ERROR_INVALID_STATE;
}
else
result = ERROR_INVALID_STATE;
return result;
}
示例2: PickFreeItem
TItem* CItemPool::PickFreeItem()
{
TItem* pItem = nullptr;
if(m_lsFreeItem.TryGet(&pItem))
pItem->Reset();
else
pItem = TItem::Construct(m_heap, m_dwItemCapacity);
return pItem;
}
示例3: CatAndPost
int CUdpServer::CatAndPost(TUdpSocketObj* pSocketObj, const BYTE* pBuffer, int iLength, BOOL isPostSend)
{
int result = NO_ERROR;
TItem* pItem = m_itPool.PickFreeItem();
pItem->Cat(pBuffer, iLength);
pSocketObj->sndBuff.PushBack(pItem);
pSocketObj->pending += iLength;
if(isPostSend && !::PostIocpSend(m_hCompletePort, pSocketObj->connID))
result = ::GetLastError();
return result;
}
示例4: while
int TItemList::Reduce(int length)
{
int remain = length;
while(remain > 0 && Size() > 0)
{
TItem* pItem = Front();
remain -= pItem->Reduce(remain);
if(pItem->IsEmpty())
itPool.PutFreeItem(PopFront());
}
return length - remain;
}
示例5: Front
int TItemList::Peek(BYTE* pData, int length)
{
int remain = length;
TItem* pItem = Front();
while(remain > 0 && pItem != nullptr)
{
int peek = pItem->Peek(pData, remain);
pData += peek;
remain -= peek;
pItem = pItem->next;
}
return length - remain;
}
示例6: locallock
TItem* CItemPool::PickFreeItem()
{
TItem* pItem = nullptr;
if(m_lsFreeItem.Size() > 0)
{
CCriSecLock locallock(m_csFreeItem);
if(m_lsFreeItem.Size() > 0)
pItem = m_lsFreeItem.PopFront();
}
if(pItem == nullptr)
pItem = TItem::Construct(m_heap, m_dwItemCapacity);
else
pItem->Reset();
return pItem;
}
示例7: ASSERT
BOOL CUdpServer::Send(CONNID dwConnID, const BYTE* pBuffer, int iLength, int iOffset)
{
ASSERT(pBuffer && iLength > 0 && iLength <= (int)m_dwMaxDatagramSize);
if(iOffset != 0) pBuffer += iOffset;
if(!pBuffer || iLength <= 0 || iLength > (int)m_dwMaxDatagramSize)
{
::SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
int result = NO_ERROR;
TUdpSocketObj* pSocketObj = FindSocketObj(dwConnID);
if(!TUdpSocketObj::IsValid(pSocketObj))
result = ERROR_OBJECT_NOT_FOUND;
else
{
CCriSecLock locallock(pSocketObj->crisec);
if(!TUdpSocketObj::IsValid(pSocketObj))
result = ERROR_OBJECT_NOT_FOUND;
else
{
BOOL isPending = TUdpSocketObj::IsPending(pSocketObj);
TItem* pItem = m_itPool.PickFreeItem();
pItem->Cat(pBuffer, iLength);
pSocketObj->sndBuff.PushBack(pItem);
pSocketObj->pending += iLength;
if(!isPending && !::PostIocpSend(m_hCompletePort, dwConnID))
result = ::GetLastError();
}
}
if(result != NO_ERROR)
::SetLastError(result);
return (result == NO_ERROR);
}
示例8: pop
virtual TItem* pop() {
TItem* item = 0;
if ((item = first_)) {
TItem* next = 0;
if ((next = item->next()))
next->set_prev(0);
else last_ = 0;
first_ = next;
item->set_next(0);
item->set_prev(0);
}
return item;
}
示例9: pull
virtual TItem* pull() {
TItem* item = 0;
if ((item = last_)) {
TItem* prev = 0;
if ((prev = item->prev()))
prev->set_next(0);
else first_ = 0;
last_ = prev;
item->set_next(0);
item->set_prev(0);
}
return item;
}
示例10: Cat
inline int TItem::Cat(const TItem& other)
{
ASSERT(this != &other);
return Cat(other.Ptr(), other.Size());
}