本文整理汇总了C++中PacketPtr::stop_Timer方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketPtr::stop_Timer方法的具体用法?C++ PacketPtr::stop_Timer怎么用?C++ PacketPtr::stop_Timer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketPtr
的用法示例。
在下文中一共展示了PacketPtr::stop_Timer方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send
int Message::send( XPlat_Socket sock_fd )
{
ssize_t sret;
size_t buf_len, total_bytes = 0;
Stream* strm;
PerfDataMgr* pdm = NULL;
uint64_t *packet_sizes = NULL;
char *buf = NULL;
XPlat::SocketUtils::NCBuf* ncbufs;
Timer tmp;
unsigned int i, j;
int packetLength, rc = 0;
uint32_t num_packets, num_buffers, num_ncbufs;
PDR pdrs;
enum pdr_op op = PDR_ENCODE;
bool using_prealloc = true;
bool go_away = false;
PacketPtr pkt;
std::list< PacketPtr > send_packets;
std::list< PacketPtr >::iterator piter;
_packet_sync.Lock();
_send_sync.Lock();
if( _packets.size() == 0 ) { //nothing to do
mrn_dbg( 3, mrn_printf(FLF, stderr, "Nothing to send!\n") );
_packet_sync.Unlock();
_send_sync.Unlock();
return 0;
}
send_packets = _packets;
_packets.clear();
_packet_sync.Unlock();
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 ) {
if( pdm->is_Enabled(PERFDATA_MET_ELAPSED_SEC,
PERFDATA_CTX_PKT_SEND) ) {
pkt->start_Timer(PERFDATA_PKT_TIMERS_SEND);
pkt->stop_Timer(PERFDATA_PKT_TIMERS_FILTER_TO_SEND);
}
}
}
}
// Allocation (if required)
num_packets = uint32_t(send_packets.size());
num_buffers = num_packets * 2;
num_ncbufs = num_buffers + 2;
buf_len = ((size_t)num_buffers * sizeof(uint64_t)) + 1; //1 extra bytes overhead
if( num_ncbufs < _ncbuf_len ) {
buf = _packet_sizes_buf;
ncbufs = _ncbuf;
packet_sizes = _packet_sizes;
}
else {
using_prealloc = false;
buf = (char*) malloc( buf_len );
ncbufs = new XPlat::SocketUtils::NCBuf[ num_ncbufs ];
packet_sizes = (uint64_t*) malloc( sizeof(uint64_t) * num_buffers );
}
//
// packets
//
piter = send_packets.begin();
for( i = 0; piter != send_packets.end(); piter++, i += 2 ) {
/* j accounts for skipping first two ncbufs that hold pkt count and sizes */
j = i + 2;
PacketPtr& curPacket = *piter;
/* check for final packet */
int tag = curPacket->get_Tag();
if( (tag == PROT_SHUTDOWN) || (tag == PROT_SHUTDOWN_ACK) )
go_away = true;
uint32_t hsz = curPacket->get_HeaderLen();
uint64_t dsz = curPacket->get_BufferLen();
if( hsz == 0 ) {
/* lazy encoding of packet header */
curPacket->encode_pdr_header();
hsz = curPacket->get_HeaderLen();
}
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;
//.........这里部分代码省略.........