本文整理汇总了C++中Stream::HandleRpcResponse方法的典型用法代码示例。如果您正苦于以下问题:C++ Stream::HandleRpcResponse方法的具体用法?C++ Stream::HandleRpcResponse怎么用?C++ Stream::HandleRpcResponse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream::HandleRpcResponse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Consume
int Stream::Consume(void *meta, bthread::TaskIterator<butil::IOBuf*>& iter) {
Stream* s = (Stream*)meta;
s->StopIdleTimer();
if (iter.is_queue_stopped()) {
// indicating the queue was closed
if (s->_host_socket) {
DereferenceSocket(s->_host_socket);
s->_host_socket = NULL;
}
if (s->_options.handler != NULL) {
s->_options.handler->on_closed(s->id());
}
delete s;
return 0;
}
DEFINE_SMALL_ARRAY(butil::IOBuf*, buf_list, s->_options.messages_in_batch, 256);
MessageBatcher mb(buf_list, s->_options.messages_in_batch, s);
bool has_timeout_task = false;
for (; iter; ++iter) {
butil::IOBuf* t= *iter;
if (t == TIMEOUT_TASK) {
has_timeout_task = true;
} else {
if (s->_parse_rpc_response) {
s->_parse_rpc_response = false;
s->HandleRpcResponse(t);
} else {
mb.push(t);
}
}
}
if (s->_options.handler != NULL) {
if (has_timeout_task && mb.total_length() == 0) {
s->_options.handler->on_idle_timeout(s->id());
}
}
mb.flush();
if (s->_remote_settings.need_feedback() && mb.total_length() > 0) {
s->_local_consumed += mb.total_length();
s->SendFeedback();
}
s->StartIdleTimer();
return 0;
}