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


C++ PacketPtr::set_OutgoingPktCount方法代码示例

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


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

示例1: send


//.........这里部分代码省略.........
        ncbufs[j].buf = const_cast< char* >( curPacket->get_Header() );
        ncbufs[j].len = hsz;
        packet_sizes[i] = (uint64_t)hsz;

        ncbufs[j+1].buf = const_cast< char* >( curPacket->get_Buffer() );
        ncbufs[j+1].len = size_t(dsz);
        packet_sizes[i+1] = (uint64_t)dsz;

        total_bytes += (size_t)hsz + (size_t)dsz;
    }

    //
    // packet count
    //
    pdrmem_create( &pdrs, &(_packet_count_buf[1]), _packet_count_buf_len, op, pdrmem_getbo() );
    pdr_uint32(&pdrs, &num_packets);
    ncbufs[0].buf = _packet_count_buf;
    ncbufs[0].len = size_t(_packet_count_buf_len + 1);
    _packet_count_buf[0] = (char) pdrmem_getbo();
    //
    // packet sizes
    //
    pdrmem_create( &pdrs, buf, buf_len, op, pdrmem_getbo() );
    if( ! pdr_vector(&pdrs, (char*)packet_sizes, num_buffers, 
                     sizeof(uint64_t), (pdrproc_t)pdr_uint64) ) {
        mrn_dbg( 1, mrn_printf(FLF, stderr, "pdr_vector() failed\n" ));
        rc = -1;
        goto send_cleanup_return;
    }
    ncbufs[1].buf = buf;
    ncbufs[1].len = buf_len;

    // Send it all
    sret = XPlat::SocketUtils::Send( sock_fd, ncbufs, num_ncbufs );
    if( sret < (ssize_t)(total_bytes + _packet_count_buf_len + buf_len + 1) ) {
        mrn_dbg( 1, mrn_printf(FLF, stderr,
                               "XPlat::SocketUtils::Send() returned %" PRIsszt
		               " of %" PRIszt" bytes, nbuffers = %u\n",
                               sret, total_bytes, num_buffers ));
        rc = -1;
        goto send_cleanup_return;
    }

    packetLength = (int) send_packets.size();
    piter = send_packets.begin();
    for( ; piter != send_packets.end(); piter++ ) {
        pkt = *piter;
        strm = _net->get_Stream( pkt->get_StreamId() );
        if( NULL != strm ) {
            pdm = strm->get_PerfData();
            if( NULL != pdm ) {
                pkt->set_Timer( PERFDATA_PKT_TIMERS_RECV_TO_FILTER, tmp );
                if( pdm->is_Enabled(PERFDATA_MET_ELAPSED_SEC, 
                                    PERFDATA_CTX_PKT_SEND) ) {
                    pkt->set_OutgoingPktCount( packetLength );
                    pkt->stop_Timer( PERFDATA_PKT_TIMERS_SEND );
                    pdm->add_PacketTimers( pkt );
                }   
                else if( pdm->is_Enabled(PERFDATA_MET_ELAPSED_SEC,  PERFDATA_CTX_PKT_NET_SENDCHILD) || 
                     pdm->is_Enabled(PERFDATA_MET_ELAPSED_SEC, PERFDATA_CTX_PKT_NET_SENDPAR) ||
                     pdm->is_Enabled(PERFDATA_MET_ELAPSED_SEC, PERFDATA_CTX_PKT_FILTER_TO_SEND)) 
                {
                    pdm->add_PacketTimers( pkt );
                }
            }
        }
    }

 send_cleanup_return:
    _send_sync.Unlock();

    if( ! using_prealloc ) {
        free( buf );
        free( packet_sizes );
        delete[] ncbufs;
    }

    if( go_away ) {
        // exit send thread
        mrn_dbg( 5, mrn_printf(FLF, stderr, "I'm going away now!\n" ));
        tsd_t* tsd = (tsd_t*)XPlat::XPlat_TLSKey->GetUserData();
        if( NULL != tsd ) {
            delete tsd;
            if(XPlat::XPlat_TLSKey->SetUserData(NULL) != 0) {
                mrn_dbg(1, mrn_printf(FLF, stderr, "Thread 0x%lx failed to set"
                            " thread-specific user data to NULL.\n",
                            XPlat::Thread::GetId()));
            }
            if(XPlat::XPlat_TLSKey->DestroyData() != 0) {
                mrn_dbg(1, mrn_printf(FLF, stderr, "Thread 0x%lx failed to "
                            "destroy thread-specific data.\n",
                            XPlat::Thread::GetId()));
            }
        }
        XPlat::Thread::Exit(NULL);
    }    

    mrn_dbg_func_end();
    return rc;
}
开发者ID:bwelton,项目名称:mrnet,代码行数:101,代码来源:Message.C


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