本文整理汇总了C++中TcpConnectionPtr::getLoop方法的典型用法代码示例。如果您正苦于以下问题:C++ TcpConnectionPtr::getLoop方法的具体用法?C++ TcpConnectionPtr::getLoop怎么用?C++ TcpConnectionPtr::getLoop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TcpConnectionPtr
的用法示例。
在下文中一共展示了TcpConnectionPtr::getLoop方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeConnection
void TcpClient::removeConnection(const TcpConnectionPtr& conn)
{
loop_->assertInLoopThread();
assert(loop_ == conn->getLoop());
assert(connection_ == conn);
loop_->queueInLoop(std::bind(&TcpConnection::connectDestroyed, conn));
}
示例2: removeConnectionInLoop
void TcpServer::removeConnectionInLoop(const TcpConnectionPtr& conn)
{
_loop->assertInLoopThread();
size_t n = _connections.erase(conn->name());
(void)n;
assert(n == 1);
EventLoop* ioLoop = conn->getLoop();
ioLoop->queueInLoop(
std::bind(&TcpConnection::connectDestroyed, conn));
}
示例3: removeConnectionInLoop
void TcpServer::removeConnectionInLoop(const TcpConnectionPtr& conn)
{
m_loop->assertInLoopThread();
LOG_INFO << "TcpServer::removeConnectionInLoop [" << m_name
<< "] - connection " << conn->name();
size_t n = connections_.erase(conn->name());
(void)n;
assert(n == 1);
EventLoop* ioLoop = conn->getLoop();
ioLoop->queueInLoop(
boost::bind(&TcpConnection::connectDestroyed, conn));
}
示例4: removeConnectionInLoop
void TcpServer::removeConnectionInLoop(const TcpConnectionPtr& conn)
{
loop_->assertInLoopThread();
LOG_PRINT(LogType_Info, "TcpServer::removeConnectionInLoop [%s] - connection %s",
name_.c_str(), conn->name().c_str());
size_t n = connections_.erase(conn->name());
(void)n;
assert(n == 1);
EventLoop* loop = conn->getLoop();
loop->queueInLoop(
std::bind(&TcpConnection::connectDestroyed, conn));
}
示例5:
TcpServer::~TcpServer()
{
_loop->assertInLoopThread();
for (ConnectionMap::iterator it(_connections.begin());
it != _connections.end(); ++it)
{
TcpConnectionPtr conn = it->second;
it->second.reset();
conn->getLoop()->runInLoop(
std::bind(&TcpConnection::connectDestroyed, conn));
conn.reset();
}
}
示例6:
TcpServer::~TcpServer()
{
m_loop->assertInLoopThread();
LOG_TRACE << "TcpServer::~TcpServer [" << m_name << "] destructing";
for (ConnectionMap::iterator it(connections_.begin());
it != connections_.end(); ++it)
{
TcpConnectionPtr conn = it->second;
it->second.reset();
conn->getLoop()->runInLoop(
boost::bind(&TcpConnection::connectDestroyed, conn));
conn.reset();
}
}
示例7:
TcpServer::~TcpServer()
{
loop_->assertInLoopThread();
LOG_PRINT(LogType_Info, "TcpServer::~TcpServer [%s] destructing", name_.c_str());
for(ConnectionMap::iterator it(connections_.begin());
it != connections_.end(); ++it)
{
TcpConnectionPtr conn = it->second;
it->second.reset();
conn->getLoop()->runInLoop(
std::bind(&TcpConnection::connectDestroyed, conn));
conn.reset();
}
}
示例8: removeConnection
void TcpClient::removeConnection(const TcpConnectionPtr& conn){
loop_->assertInLoopThread();
assert(loop_ == conn->getLoop());
{
MutexLockGuard lock(mutex_);
assert(connection_ == conn);
connection_.reset();
}
loop_->queueInLoop(boost::bind(&TcpConnection::connectDestoryed, conn));
if(retry_ && connect_){
LOG_INFO << "TcpClient::connect[" << this << "] - reconnecting to "
<< connector_->serverAddress().toHostPort();
connector_->restart();
}
}
示例9: onDisconnect
void onDisconnect(const TcpConnectionPtr& conn)
{
if(numConnected_.decrement() == 0)
{
printf("all disconnected\n");
int64_t totalBytesRead = 0;
int64_t totalMessagesRead = 0;
for(std::vector<Session*>::iterator it = sessions_.begin(); it != sessions_.end(); ++it)
{
totalBytesRead += (*it)->bytesRead();
totalMessagesRead += (*it)->messagesRead();
}
printf("%ld total bytes read\n", totalBytesRead);
printf("%ld total messages read\n", totalMessagesRead);
printf("%f average message size\n", static_cast<double>(totalBytesRead) / static_cast<double>(totalMessagesRead));
printf("%f QPS\n", static_cast<double>(totalMessagesRead) / timeout_);
printf("%f MiB/s throughput\n", static_cast<double>(totalBytesRead) / (timeout_ * 1024 * 1024));
conn->getLoop()->queueInLoop(std::bind(&Client::quit, this));
}
}