本文整理汇总了C++中MemoryBlock::PopFront方法的典型用法代码示例。如果您正苦于以下问题:C++ MemoryBlock::PopFront方法的具体用法?C++ MemoryBlock::PopFront怎么用?C++ MemoryBlock::PopFront使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemoryBlock
的用法示例。
在下文中一共展示了MemoryBlock::PopFront方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Pop
/**
* Remove the first n bytes from the buffer
*/
void IOQueue::Pop(unsigned int n) {
unsigned int bytes_popped = 0;
BlockVector::iterator iter = m_blocks.begin();
while (iter != m_blocks.end() && bytes_popped != n) {
MemoryBlock *block = *iter;
bytes_popped += block->PopFront(n - bytes_popped);
if (block->Empty()) {
m_pool->Release(block);
iter = m_blocks.erase(iter);
} else {
iter++;
}
}
}
示例2: Pop
/**
* Remove bytes from the stack
*/
void IOStack::Pop(unsigned int bytes_to_remove) {
unsigned int bytes_removed = 0;
BlockVector::iterator iter = m_blocks.begin();
while (iter != m_blocks.end() && bytes_removed != bytes_to_remove) {
MemoryBlock *block = *iter;
bytes_removed += block->PopFront(bytes_to_remove - bytes_removed);
if (block->Empty()) {
m_pool->Release(block);
iter = m_blocks.erase(iter);
} else {
iter++;
}
}
}
示例3: Read
/**
* Read up to n bytes into the memory location data and shrink the IOQueue by
* the amount read.
*/
unsigned int IOQueue::Read(uint8_t *data, unsigned int n) {
unsigned int bytes_read = 0;
BlockVector::iterator iter = m_blocks.begin();
while (iter != m_blocks.end() && bytes_read != n) {
MemoryBlock *block = *iter;
unsigned int bytes_copied = block->Copy(data + bytes_read, n - bytes_read);
block->PopFront(bytes_copied);
bytes_read += bytes_copied;
if (block->Empty()) {
m_pool->Release(block);
iter = m_blocks.erase(iter);
} else {
iter++;
}
}
return bytes_read;
}