本文整理汇总了C++中asynciovector::iterator::start方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::start方法的具体用法?C++ iterator::start怎么用?C++ iterator::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类asynciovector::iterator
的用法示例。
在下文中一共展示了iterator::start方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: asyncWrite
int eDVBRecordFileThread::asyncWrite(int len)
{
#ifdef SHOW_WRITE_TIME
struct timeval starttime;
struct timeval now;
suseconds_t diff;
gettimeofday(&starttime, NULL);
#endif
m_ts_parser.parseData(m_current_offset, m_buffer, len);
#ifdef SHOW_WRITE_TIME
gettimeofday(&now, NULL);
diff = (1000000 * (now.tv_sec - starttime.tv_sec)) + now.tv_usec - starttime.tv_usec;
eDebug("[eFilePushThreadRecorder] m_ts_parser.parseData: %9u us", (unsigned int)diff);
gettimeofday(&starttime, NULL);
#endif
int r = m_current_buffer->start(m_fd_dest, m_current_offset, len, m_buffer);
if (r < 0)
{
eDebug("[eDVBRecordFileThread] aio_write failed: %m");
return r;
}
m_current_offset += len;
#ifdef SHOW_WRITE_TIME
gettimeofday(&now, NULL);
diff = (1000000 * (now.tv_sec - starttime.tv_sec)) + now.tv_usec - starttime.tv_usec;
eDebug("[eFilePushThreadRecorder] aio_write: %9u us", (unsigned int)diff);
#endif
// Count how many buffers are still "busy". Move backwards from current,
// because they can reasonably be expected to finish in that order.
AsyncIOvector::iterator i = m_current_buffer;
r = i->poll();
int busy_count = 0;
while (r > 0)
{
++busy_count;
if (i == m_aio.begin())
i = m_aio.end();
--i;
if (i == m_current_buffer)
{
eDebug("[eFilePushThreadRecorder] Warning: All write buffers busy");
break;
}
r = i->poll();
if (r < 0)
return r;
}
++m_buffer_use_histogram[busy_count];
++m_current_buffer;
if (m_current_buffer == m_aio.end())
m_current_buffer = m_aio.begin();
m_buffer = m_current_buffer->buffer;
return len;
}