本文整理汇总了C++中boost::asio::io_service::strand::post方法的典型用法代码示例。如果您正苦于以下问题:C++ strand::post方法的具体用法?C++ strand::post怎么用?C++ strand::post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::asio::io_service::strand
的用法示例。
在下文中一共展示了strand::post方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: nextOperation
/// Connection base state machine
void nextOperation()
{
NetworkOperation netOp = m_connHandler->nextOperation();
switch ( netOp.operation() ) {
case NetworkOperation::READ: {
LOG_TRACE << "Next operation: READ " << netOp.size() << " bytes from " << identifier();
if ( netOp.buffer() == NULL ) {
LOG_FATAL << "Attempt to READ from " << identifier() << " to a NULL data block";
abort(); // here should be a system exception
}
if ( netOp.size() == 0 ) {
LOG_FATAL << "Attempt to READ 0 bytes data block from " << identifier();
abort(); // here should be a system exception
}
if ( netOp.timeout() > 0 )
setTimeout( netOp.timeout());
m_readBuffer = netOp.buffer();
socket().async_read_some( boost::asio::buffer( m_readBuffer, netOp.size() ),
m_strand.wrap( boost::bind( &ConnectionBase::handleRead,
this->shared_from_this(),
boost::asio::placeholders::error,
boost::asio::placeholders::bytes_transferred )));
break;
}
case NetworkOperation::WRITE: {
LOG_TRACE << "Next operation: WRITE " << netOp.size() << " bytes to " << identifier();
if ( netOp.data() == NULL ) {
LOG_FATAL << "Attempt to WRITE a NULL data block to " << identifier();
abort(); // here should be a system exception
}
if ( netOp.size() == 0 ) {
LOG_FATAL << "Attempt to WRITE a 0 bytes data block to " << identifier();
abort(); // here should be a system exception
}
if ( netOp.timeout() > 0 )
setTimeout( netOp.timeout());
boost::asio::async_write( socket(),
boost::asio::buffer( netOp.data(), netOp.size() ),
m_strand.wrap( boost::bind( &ConnectionBase::handleWrite,
this->shared_from_this(),
boost::asio::placeholders::error )));
break;
}
case NetworkOperation::CLOSE: {
LOG_TRACE << "Next operation: CLOSE connection to " << identifier();
// Initiate graceful connection closure.
setTimeout( 0 );
unregister();
m_strand.post( boost::bind( &ConnectionBase::handleShutdown,
this->shared_from_this() ));
break;
}
case NetworkOperation::NOOP:
LOG_TRACE << "Next operation: NOOP on connection to " << identifier();
break;
}
}
示例2: PostRandomTicket
void CAuthenticationCenter::PostRandomTicket(boost::shared_ptr<CTcpConnection> conn,
boost::asio::io_service::strand& strand,
const std::string& secret_key,std::vector<std::string> command_vec)
{
strand.post(boost::bind(&CAuthenticationCenter::ProcessTicketMessage,this,
conn,secret_key,command_vec));
}
示例3: process_message
void process_message(message_ptr msg)
{
//std::cout << ">";
unsigned int msgid;
msg->get_object<unsigned int>(msgid);
logfile.log(boost::lexical_cast<std::string>(msgid));
//do_stuff(); //TODO: find a way to do_stuff() concurrently
reply_strand_.post(boost::bind(&session::send_reply, shared_from_this(), msg));
}
示例4: PostErrorMessage
void CAuthenticationCenter::PostErrorMessage(boost::shared_ptr<CTcpConnection> conn,
boost::asio::io_service::strand& strand,
const std::string& errmsg)
{
strand.post(boost::bind(
&CAuthenticationCenter::ReplyErrorMessage,
this,conn,errmsg
));
}
示例5: handle_read
void handle_read(message_ptr msg,
const boost::system::error_code & error,
size_t bytes_transferred)
{
if (!error)
{
request_strand_.post(boost::bind(&session::process_message, shared_from_this(), msg));
poll_message();
}
else
{
error_handler_(error);
}
}
示例6: PostRandomTGT
void CAuthenticationCenter::PostRandomTGT(boost::shared_ptr<CTcpConnection> conn,
boost::asio::io_service::strand& strand,
UserInfo &unode)
{
strand.post(boost::bind(&CAuthenticationCenter::ProcessTGTMessage,this,conn,unode));
}