本文整理汇总了C++中StreamBuffer::beginWrite方法的典型用法代码示例。如果您正苦于以下问题:C++ StreamBuffer::beginWrite方法的具体用法?C++ StreamBuffer::beginWrite怎么用?C++ StreamBuffer::beginWrite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StreamBuffer
的用法示例。
在下文中一共展示了StreamBuffer::beginWrite方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onOutput
bool Socket::onOutput(StreamBuffer& sb)
{
log_trace("onOutput");
log_debug("send data to " << getPeerAddr());
try
{
sb.endWrite();
if ( sb.out_avail() )
{
sb.beginWrite();
}
else
{
if (sb.in_avail())
onInput(sb);
else
sb.beginRead();
}
}
catch (const std::exception& e)
{
log_warn("exception occured when processing request: " << e.what());
close();
return false;
}
return true;
}
示例2: onOutput
void RpcClientImpl::onOutput(StreamBuffer& sb)
{
try
{
_exceptionPending = false;
sb.endWrite();
if (sb.out_avail() > 0)
sb.beginWrite();
else
sb.beginRead();
}
catch (const std::exception&)
{
IRemoteProcedure* proc = _proc;
cancel();
if (!proc)
throw;
_exceptionPending = true;
proc->onFinished();
if (_exceptionPending)
throw;
}
}
示例3: onOutput
void ClientImpl::onOutput(StreamBuffer& sb)
{
log_trace("ClientImpl::onOutput; out_avail=" << sb.out_avail());
try
{
try
{
_errorPending = false;
sb.endWrite();
if( sb.out_avail() > 0 )
{
sb.beginWrite();
}
else
{
sb.beginRead();
_client->requestSent(*_client);
_parser.reset(true);
_readHeader = true;
}
}
catch (const IOError& e)
{
if (_reconnectOnError && _request != 0)
{
log_debug("reconnect on error");
_socket.close();
_reconnectOnError = false;
reexecuteBegin(*_request);
return;
}
throw;
}
}
catch (const std::exception& e)
{
log_warn("error of type " << typeid(e).name() << " occured: " << e.what());
_errorPending = true;
_client->replyFinished(*_client);
if (_errorPending)
throw;
}
}
示例4: onOutput
bool Socket::onOutput(StreamBuffer& sb)
{
log_trace("onOutput");
log_debug("send data to " << getPeerAddr());
try
{
sb.endWrite();
if ( sb.out_avail() )
{
sb.beginWrite();
_timer.start(_server.writeTimeout());
}
else
{
bool keepAlive = _request.header().keepAlive()
&& _reply.header().keepAlive();
if (keepAlive)
{
log_debug("do keep alive");
_timer.start(_server.keepAliveTimeout());
_request.clear();
_reply.clear();
_parser.reset(false);
if (sb.in_avail())
onInput(sb);
else
_stream.buffer().beginRead();
}
else
{
log_debug("don't do keep alive");
close();
return false;
}
}
}
catch (const std::exception& e)
{
log_warn("exception occured when processing request: " << e.what());
close();
timeout(*this);
return false;
}
return true;
}
示例5: onInput
void Socket::onInput(StreamBuffer& sb)
{
log_debug("onInput");
sb.endRead();
if (sb.in_avail() == 0 || sb.device()->eof())
{
close();
return;
}
if (_responder.onInput(_stream))
{
sb.beginWrite();
onOutput(sb);
}
else
{
sb.beginRead();
}
}