当前位置: 首页>>代码示例>>C++>>正文


C++ MessageHeader::getFragmentOffset方法代码示例

本文整理汇总了C++中MessageHeader::getFragmentOffset方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageHeader::getFragmentOffset方法的具体用法?C++ MessageHeader::getFragmentOffset怎么用?C++ MessageHeader::getFragmentOffset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MessageHeader的用法示例。


在下文中一共展示了MessageHeader::getFragmentOffset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: checkAndLogMsg

PtrLList<Message> * NetworkTrafficMemory::filterRecentlySent (Message *pMsg, int64 i64RequestArrivalTime)
{
    _m.lock (186);
    MessageHeader *pMH = pMsg->getMessageHeader();
    if (pMH == NULL) {
        checkAndLogMsg ("NetworkTrafficMemory::filterRecentlySent", Logger::L_Warning,
                        "Message object does not contain message header.\n");
    }

    PtrLList<Message> *pRet = new PtrLList<Message>();
    if (pRet == NULL) {
        checkAndLogMsg ("NetworkTrafficMemory::filterRecentlySent", memoryExhausted);
        _m.unlock (186);
        return NULL;
    }

    if (_ui16IgnoreRequestTime == 0) {
        pRet->insert (new Message (pMH->clone(), pMsg->getData()));
         _m.unlock (186);
        return pRet;
    }

    MessagesByGroup *pBG = _messageByGroup.get (pMH->getGroupName());
    if (pBG == NULL) {
        pRet->insert (new Message (pMH->clone(), pMsg->getData()));
         _m.unlock (186);
        return pRet;
    }

    MessagesBySender *pMS = pBG->messageBySender.get (pMH->getPublisherNodeId());
    if (pMS == NULL) {
        pRet->insert (new Message (pMH->clone(), pMsg->getData()));
         _m.unlock (186);
        return pRet;
    }

    FragmentedMessageHeader *pFMH = pMS->messageBySeqId.get (pMH->getMsgSeqId());
    if (pFMH == NULL) {
        pRet->insert (new Message (pMH->clone(), pMsg->getData()));
         _m.unlock (186);
        return pRet;
    }

    if (pMH->isChunk()) {
        FragmentedChunk *pFC = ((FragmentedMessage *) pFMH)->chunksByChunkId.get (pMsg->getChunkMsgInfo()->getChunkId());
        if (pFC == NULL) {
            pRet->insert (new Message (pMH->clone(), pMsg->getData()));
            _m.unlock (186);
            return pRet;
        }
        else {
            pFMH = pFC;
        }
    }

    char *psFragToSendData;
    psFragToSendData = (char *) pMsg->getData();
    uint32 ui32FragToSendStart = pMH->getFragmentOffset();
    uint32 ui32FragToSendEnd = ui32FragToSendStart + pMH->getFragmentLength();

    MessageHeader *pTmpMI;

    for (FragmentWrapper *pFW = pFMH->fragments.getFirst(); (pFW != NULL) && (ui32FragToSendEnd > pFW->ui32Offset); pFW = pFMH->fragments.getNext()) {
        if (pFW->overlaps (ui32FragToSendStart, ui32FragToSendEnd)) {
            if ((i64RequestArrivalTime - pFW->i64LastServingTime) < _ui16IgnoreRequestTime) {
                // I need to split
                // write everything before pFW->ui32Offset
                uint32 ui32TmpFragLength = (ui32FragToSendStart < pFW->ui32Offset ? pFW->ui32Offset - ui32FragToSendStart : (uint32) 0);
                if (ui32TmpFragLength > 0) {
                    pTmpMI = pMH->clone();
                    pTmpMI->setFragmentOffset (ui32FragToSendStart);
                    pTmpMI->setFragmentLength (ui32TmpFragLength);
                    pRet->insert (new Message (pTmpMI, psFragToSendData));
                }
                // ui32FragToSendStart = pFW->ui32End;
                // psFragToSendData = psFragToSendData + ui32TmpFragLength;
                ui32TmpFragLength = minimum (pFW->ui32End, ui32FragToSendEnd) - ui32FragToSendStart;
                ui32FragToSendStart += ui32TmpFragLength;
                psFragToSendData += ui32TmpFragLength;
            }
        }
    }
    // Add the remaining part
    if (ui32FragToSendStart < ui32FragToSendEnd) {
        pTmpMI = pMH->clone();
        pTmpMI->setFragmentOffset (ui32FragToSendStart);
        pTmpMI->setFragmentLength (ui32FragToSendEnd - ui32FragToSendStart);
        pRet->insert (new Message (pTmpMI, psFragToSendData));
    }
    _m.unlock (186);
    return pRet;
}
开发者ID:agilecomputing,项目名称:nomads,代码行数:92,代码来源:NetworkTrafficMemory.cpp


注:本文中的MessageHeader::getFragmentOffset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。