本文整理汇总了C++中PacketQueue::end方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketQueue::end方法的具体用法?C++ PacketQueue::end怎么用?C++ PacketQueue::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketQueue
的用法示例。
在下文中一共展示了PacketQueue::end方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processAck
void ReliabilitySystem::processAck( quint32 ack
, quint32 ack_bits
, PacketQueue & pending_ack_queue
, PacketQueue & acked_queue
, QVector<quint32> & acked
, quint32 & acked_packets
, float & rtt
, quint32 max_sequence)
{
if ( pending_ack_queue.empty() ){
return;
}
PacketQueue::iterator itor = pending_ack_queue.begin();
while ( itor != pending_ack_queue.end() ) {
bool wasAcked = false;
if ( itor->sequence == ack ) {
wasAcked = true;
}
else if ( !sequenceIsMoreRecent( itor->sequence, ack, max_sequence ) ) {
qint32 bit_index = bitIndexForSequence( itor->sequence, ack, max_sequence );
if ( bit_index <= 31 ){
wasAcked = ( ack_bits >> bit_index ) & 1;
}
}
示例2: process_ack
void ReliabilitySystem::process_ack( unsigned int ack, unsigned int ack_bits,
PacketQueue & pending_ack_queue, PacketQueue & acked_queue,
std::vector<unsigned int> & acks, unsigned int & acked_packets,
float & rtt, unsigned int max_sequence )
{
if ( pending_ack_queue.empty() ) {
return;
}
PacketQueue::iterator itor = pending_ack_queue.begin();
while ( itor != pending_ack_queue.end() )
{
bool acked = false;
if ( itor->sequence == ack )
{
acked = true;
}
else if ( !sequence_more_recent( itor->sequence, ack, max_sequence ) )
{
int bit_index = bit_index_for_sequence( itor->sequence, ack, max_sequence );
if ( bit_index <= 31 ) {
acked = ( ack_bits >> bit_index ) & 1;
}
}
示例3: process_ack
void ReliabilitySystem::process_ack(unsigned int ack, unsigned int ack_bits,
PacketQueue & pending_ack_queue, PacketQueue & acked_queue,
std::vector<unsigned int> & acks, unsigned int & acked_packets,
float & rtt, unsigned int max_sequence)
{
if (pending_ack_queue.empty())
return;
PacketQueue::iterator itor = pending_ack_queue.begin();
while (itor != pending_ack_queue.end()) {
bool acked = false;
if (itor->sequence == ack) {
acked = true;
} else if (!sequence_more_recent(itor->sequence, ack, max_sequence)) {
int bit_index = bit_index_for_sequence(itor->sequence, ack, max_sequence);
if (bit_index <= 31)
acked = (ack_bits >> bit_index) & 1;
}
if (acked) {
rtt += (itor->time - rtt) * 0.1f;
acked_queue.insert_sorted(*itor, max_sequence);
acks.push_back(itor->sequence);
acked_packets++;
itor = pending_ack_queue.erase(itor);
} else {
++itor;
}
}
示例4: generate_ack_bits
unsigned int ReliabilitySystem::generate_ack_bits(unsigned int ack, const PacketQueue & received_queue, unsigned int max_sequence) {
unsigned int ack_bits = 0;
for (PacketQueue::const_iterator itor = received_queue.begin(); itor != received_queue.end(); itor++) {
if (itor->sequence == ack || sequence_more_recent(itor->sequence, ack, max_sequence))
break;
int bit_index = bit_index_for_sequence(itor->sequence, ack, max_sequence);
if (bit_index <= 31)
ack_bits |= 1 << bit_index;
}
return ack_bits;
}
示例5: generateAckBits
quint32 ReliabilitySystem::generateAckBits( quint32 ack, const PacketQueue & received_queue, quint32 max_sequence ) {
quint32 ack_bits = 0;
for ( PacketQueue::const_iterator itor = received_queue.begin(); itor != received_queue.end(); itor++ ) {
if ( itor->sequence == ack || sequenceIsMoreRecent( itor->sequence, ack, max_sequence ) ){
break;
}
qint32 bit_index = bitIndexForSequence( itor->sequence, ack, max_sequence );
if ( bit_index <= 31 ){
ack_bits |= 1 << bit_index;
}
}
return ack_bits;
}
示例6: test_reliability_system
void test_reliability_system()
{
printf( "-----------------------------------------------------\n" );
printf( "test reliability system\n" );
printf( "-----------------------------------------------------\n" );
const int MaximumSequence = 255;
printf( "check bit index for sequence\n" );
check( ReliabilitySystem::bit_index_for_sequence( 99, 100, MaximumSequence ) == 0 );
check( ReliabilitySystem::bit_index_for_sequence( 90, 100, MaximumSequence ) == 9 );
check( ReliabilitySystem::bit_index_for_sequence( 0, 1, MaximumSequence ) == 0 );
check( ReliabilitySystem::bit_index_for_sequence( 255, 0, MaximumSequence ) == 0 );
check( ReliabilitySystem::bit_index_for_sequence( 255, 1, MaximumSequence ) == 1 );
check( ReliabilitySystem::bit_index_for_sequence( 254, 1, MaximumSequence ) == 2 );
check( ReliabilitySystem::bit_index_for_sequence( 254, 2, MaximumSequence ) == 3 );
printf( "check generate ack bits\n");
PacketQueue packetQueue;
for ( int i = 0; i < 32; ++i )
{
PacketData data;
data.sequence = i;
packetQueue.insert_sorted( data, MaximumSequence );
packetQueue.verify_sorted( MaximumSequence );
}
check( ReliabilitySystem::generate_ack_bits( 32, packetQueue, MaximumSequence ) == 0xFFFFFFFF );
check( ReliabilitySystem::generate_ack_bits( 31, packetQueue, MaximumSequence ) == 0x7FFFFFFF );
check( ReliabilitySystem::generate_ack_bits( 33, packetQueue, MaximumSequence ) == 0xFFFFFFFE );
check( ReliabilitySystem::generate_ack_bits( 16, packetQueue, MaximumSequence ) == 0x0000FFFF );
check( ReliabilitySystem::generate_ack_bits( 48, packetQueue, MaximumSequence ) == 0xFFFF0000 );
printf( "check generate ack bits with wrap\n");
packetQueue.clear();
for ( int i = 255 - 31; i <= 255; ++i )
{
PacketData data;
data.sequence = i;
packetQueue.insert_sorted( data, MaximumSequence );
packetQueue.verify_sorted( MaximumSequence );
}
check( packetQueue.size() == 32 );
check( ReliabilitySystem::generate_ack_bits( 0, packetQueue, MaximumSequence ) == 0xFFFFFFFF );
check( ReliabilitySystem::generate_ack_bits( 255, packetQueue, MaximumSequence ) == 0x7FFFFFFF );
check( ReliabilitySystem::generate_ack_bits( 1, packetQueue, MaximumSequence ) == 0xFFFFFFFE );
check( ReliabilitySystem::generate_ack_bits( 240, packetQueue, MaximumSequence ) == 0x0000FFFF );
check( ReliabilitySystem::generate_ack_bits( 16, packetQueue, MaximumSequence ) == 0xFFFF0000 );
printf( "check process ack (1)\n" );
{
PacketQueue pendingAckQueue;
for ( int i = 0; i < 33; ++i )
{
PacketData data;
data.sequence = i;
data.time = 0.0f;
pendingAckQueue.insert_sorted( data, MaximumSequence );
pendingAckQueue.verify_sorted( MaximumSequence );
}
PacketQueue ackedQueue;
std::vector<unsigned int> acks;
float rtt = 0.0f;
unsigned int acked_packets = 0;
ReliabilitySystem::process_ack( 32, 0xFFFFFFFF, pendingAckQueue, ackedQueue, acks, acked_packets, rtt, MaximumSequence );
check( acks.size() == 33 );
check( acked_packets == 33 );
check( ackedQueue.size() == 33 );
check( pendingAckQueue.size() == 0 );
ackedQueue.verify_sorted( MaximumSequence );
for ( unsigned int i = 0; i < acks.size(); ++i )
check( acks[i] == i );
unsigned int i = 0;
for ( PacketQueue::iterator itor = ackedQueue.begin(); itor != ackedQueue.end(); ++itor, ++i )
check( itor->sequence == i );
}
printf( "check process ack (2)\n" );
{
PacketQueue pendingAckQueue;
for ( int i = 0; i < 33; ++i )
{
PacketData data;
data.sequence = i;
data.time = 0.0f;
pendingAckQueue.insert_sorted( data, MaximumSequence );
pendingAckQueue.verify_sorted( MaximumSequence );
}
PacketQueue ackedQueue;
std::vector<unsigned int> acks;
float rtt = 0.0f;
unsigned int acked_packets = 0;
ReliabilitySystem::process_ack( 32, 0x0000FFFF, pendingAckQueue, ackedQueue, acks, acked_packets, rtt, MaximumSequence );
check( acks.size() == 17 );
check( acked_packets == 17 );
check( ackedQueue.size() == 17 );
check( pendingAckQueue.size() == 33 - 17 );
ackedQueue.verify_sorted( MaximumSequence );
unsigned int i = 0;
for ( PacketQueue::iterator itor = pendingAckQueue.begin(); itor != pendingAckQueue.end(); ++itor, ++i )
check( itor->sequence == i );
//.........这里部分代码省略.........