本文整理汇总了C++中OutputMessage_ptr::reset方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputMessage_ptr::reset方法的具体用法?C++ OutputMessage_ptr::reset怎么用?C++ OutputMessage_ptr::reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputMessage_ptr
的用法示例。
在下文中一共展示了OutputMessage_ptr::reset方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getOutputMessage
OutputMessage_ptr OutputMessagePool::getOutputMessage(Protocol* protocol, bool autosend /*= true*/)
{
#ifdef __DEBUG_NET_DETAIL__
std::cout << "request output message - auto = " << autosend << std::endl;
#endif
if(m_shutdown)
return OutputMessage_ptr();
OTSYS_THREAD_LOCK_CLASS lockClass(m_outputPoolLock);
if(!protocol->getConnection())
return OutputMessage_ptr();
if(m_outputMessages.empty())
{
OutputMessage* msg = new OutputMessage();
m_outputMessages.push_back(msg);
#ifdef __TRACK_NETWORK__
m_allOutputMessages.push_back(msg);
#endif
}
OutputMessage_ptr omsg;
omsg.reset(m_outputMessages.back(),
boost::bind(&OutputMessagePool::releaseMessage, this, _1));
m_outputMessages.pop_back();
configureOutputMessage(omsg, protocol, autosend);
return omsg;
}
示例2: getOutputMessage
OutputMessage_ptr OutputMessagePool::getOutputMessage(Protocol* protocol, bool autosend /*= true*/)
{
if (!m_isOpen) {
return OutputMessage_ptr();
}
std::lock_guard<std::recursive_mutex> lockClass(m_outputPoolLock);
if (!protocol->getConnection()) {
return OutputMessage_ptr();
}
if (m_outputMessages.empty()) {
OutputMessage* msg = new OutputMessage();
m_outputMessages.push_back(msg);
}
OutputMessage_ptr outputmessage;
outputmessage.reset(m_outputMessages.back(),
std::bind(&OutputMessagePool::releaseMessage, this, std::placeholders::_1));
m_outputMessages.pop_back();
configureOutputMessage(outputmessage, protocol, autosend);
return outputmessage;
}
示例3: onWriteOperation
void Connection::onWriteOperation(OutputMessage_ptr msg, const boost::system::error_code& error)
{
#ifdef __DEBUG_NET_DETAIL__
std::cout << "onWriteOperation" << std::endl;
#endif
m_connectionLock.lock();
m_writeTimer.cancel();
TRACK_MESSAGE(msg);
msg.reset();
if(error){
handleWriteError(error);
}
if(m_connectionState != CONNECTION_STATE_OPEN || m_writeError){
closeSocket();
closeConnection();
m_connectionLock.unlock();
return;
}
--m_pendingWrite;
m_connectionLock.unlock();
}
示例4: getOutputMessage
OutputMessage_ptr OutputMessagePool::getOutputMessage(Protocol* protocol, bool autosend /*= true*/)
{
#ifdef __DEBUG_NET_DETAIL__
std::cout << "request output message - auto = " << autosend << std::endl;
#endif
if(!m_isOpen){
return OutputMessage_ptr();
}
boost::recursive_mutex::scoped_lock lockClass(m_outputPoolLock);
if(protocol->getConnection() == NULL){
return OutputMessage_ptr();
}
if(m_outputMessages.empty()){
OutputMessage* msg = new OutputMessage();
m_outputMessages.push_back(msg);
#ifdef __TRACK_NETWORK__
m_allOutputMessages.push_back(msg);
#endif
}
OutputMessage_ptr outputmessage;
outputmessage.reset(m_outputMessages.back(),
boost::bind(&OutputMessagePool::releaseMessage, this, _1));
m_outputMessages.pop_back();
configureOutputMessage(outputmessage, protocol, autosend);
return outputmessage;
}
示例5: onWriteOperation
void Connection::onWriteOperation(OutputMessage_ptr msg, const boost::system::error_code& error)
{
#ifdef __DEBUG_NET_DETAIL__
std::clog << "onWriteOperation" << std::endl;
#endif
msg.reset();
m_connectionLock.lock();
if(!error)
{
if(m_pendingWrite > 0)
{
if(!m_outputQueue.empty())
{
OutputMessage_ptr msg = m_outputQueue.front();
m_outputQueue.pop_front();
internalSend(msg);
#ifdef __DEBUG_NET_DETAIL__
std::clog << "Connection::onWriteOperation send " << msg->getMessageLength() << std::endl;
#endif
}
m_pendingWrite--;
}
else
{
std::clog << "Error: [Connection::onWriteOperation] Getting unexpected notification!" << std::endl;
// Error. Pending operations counter is 0, but we are getting a
// notification!!
}
}
else
{
m_pendingWrite--;
handleWriteError(error);
}
if(m_closeState == CLOSE_STATE_CLOSING)
{
if(!closingConnection())
m_connectionLock.lock();
return;
}
m_connectionLock.unlock();
}
示例6: onWriteOperation
void Connection::onWriteOperation(OutputMessage_ptr msg, const boost::system::error_code& error)
{
std::lock_guard<std::recursive_mutex> lockClass(m_connectionLock);;
m_writeTimer.cancel();
msg.reset();
if (error) {
handleWriteError(error);
}
if (m_connectionState != CONNECTION_STATE_OPEN || m_writeError) {
closeSocket();
close();
return;
}
--m_pendingWrite;
}
示例7: onWriteOperation
void Connection::onWriteOperation(OutputMessage_ptr msg, const boost::system::error_code& error)
{
m_connectionLock.lock();
m_writeTimer.cancel();
msg.reset();
if (error) {
handleWriteError(error);
}
if (m_connectionState != CONNECTION_STATE_OPEN || m_writeError) {
closeSocket();
closeConnection();
m_connectionLock.unlock();
return;
}
--m_pendingWrite;
m_connectionLock.unlock();
}
示例8: onWrite
void Connection::onWrite(OutputMessage_ptr msg, const boost::system::error_code& error) {
LOGt("Connection::onWrite()");
boost::recursive_mutex::scoped_lock lock(m_connectionLock);
m_writeTimer.cancel();
TRACK_MESSAGE(msg);
msg.reset();
if(error)
handleWriteError(error);
if(m_connectionState != CONNECTION_STATE_OPEN || m_writeError)
{
closeSocket();
close();
return;
}
--m_pendingWrite;
}