本文整理汇总了C++中buffer_ptr_t::constructSegmentAfter方法的典型用法代码示例。如果您正苦于以下问题:C++ buffer_ptr_t::constructSegmentAfter方法的具体用法?C++ buffer_ptr_t::constructSegmentAfter怎么用?C++ buffer_ptr_t::constructSegmentAfter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类buffer_ptr_t
的用法示例。
在下文中一共展示了buffer_ptr_t::constructSegmentAfter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: process_impl
// virtual
LLIOPipe::EStatus LLIOSocketWriter::process_impl(
const LLChannelDescriptors& channels,
buffer_ptr_t& buffer,
bool& eos,
LLSD& context,
LLPumpIO* pump)
{
LL_RECORD_BLOCK_TIME(FTM_PROCESS_SOCKET_WRITER);
PUMP_DEBUG;
if(!mDestination) return STATUS_PRECONDITION_NOT_MET;
if(!mInitialized)
{
PUMP_DEBUG;
// Since the write will not block, it's ok to initialize and
// attempt to write immediately.
mInitialized = true;
if(pump)
{
PUMP_DEBUG;
LL_DEBUGS() << "Initializing poll descriptor for LLIOSocketWriter."
<< LL_ENDL;
apr_pollfd_t poll_fd;
poll_fd.p = NULL;
poll_fd.desc_type = APR_POLL_SOCKET;
poll_fd.reqevents = APR_POLLOUT;
poll_fd.rtnevents = 0x0;
poll_fd.desc.s = mDestination->getSocket();
poll_fd.client_data = NULL;
pump->setConditional(this, &poll_fd);
}
}
PUMP_DEBUG;
// *FIX: Some sort of writev implementation would be much more
// efficient - not only because writev() is better, but also
// because we won't have to do as much work to find the start
// address.
buffer->lock();
LLBufferArray::segment_iterator_t it;
LLBufferArray::segment_iterator_t end = buffer->endSegment();
LLSegment segment;
it = buffer->constructSegmentAfter(mLastWritten, segment);
/*
if(NULL == mLastWritten)
{
it = buffer->beginSegment();
segment = (*it);
}
else
{
it = buffer->getSegment(mLastWritten);
segment = (*it);
S32 size = segment.size();
U8* data = segment.data();
if((data + size) == mLastWritten)
{
++it;
segment = (*it);
}
else
{
// *FIX: check the math on this one
segment = LLSegment(
(*it).getChannelMask(),
mLastWritten + 1,
size - (mLastWritten - data));
}
}
*/
PUMP_DEBUG;
apr_size_t len;
bool done = false;
apr_status_t status = APR_SUCCESS;
while(it != end)
{
PUMP_DEBUG;
if((*it).isOnChannel(channels.in()))
{
PUMP_DEBUG;
len = (apr_size_t)segment.size();
status = apr_socket_send(
mDestination->getSocket(),
(const char*)segment.data(),
&len);
// We sometimes get a 'non-blocking socket operation could not be
// completed immediately' error from apr_socket_send. In this
// case we break and the data will be sent the next time the chain
// is pumped.
if(APR_STATUS_IS_EAGAIN(status))
{
ll_apr_warn_status(status);
break;
}
mLastWritten = segment.data() + len - 1;
PUMP_DEBUG;
//.........这里部分代码省略.........