本文整理汇总了C++中Connection::NotifyEndRequest方法的典型用法代码示例。如果您正苦于以下问题:C++ Connection::NotifyEndRequest方法的具体用法?C++ Connection::NotifyEndRequest怎么用?C++ Connection::NotifyEndRequest使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Connection
的用法示例。
在下文中一共展示了Connection::NotifyEndRequest方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Process
//.........这里部分代码省略.........
else if (IsActive() && !mTcpManager)
{
mParams = GetConnectionParams();
mActiveMax = GetActiveRequestMax();
mTcpManager = new TcpManager(mParams);
mTcpManager->SetHandler(this);
if (mTcpManager->BindAsServer()){
OnStartup();
}else{
OnFailedStartup();
return 0;
}
}
////////////////////////////////////////
// process the TcpManager
if (mTcpManager)
{
//Profile subProfile("TcpManager::GiveTime()");
mTcpManager->GiveTime();
}
// check all closed connections to see if they are idle
std::list<Connection *>::iterator closedIterator = mClosedConnections.begin();
while (closedIterator != mClosedConnections.end())
{
//Profile profile("Listener::Process (cleanup connection)");
std::list<Connection *>::iterator current = closedIterator++;
Connection * connection = *current;
if (!connection->GetActiveRequests() &&
!connection->GetQueuedRequests())
{
mClosedConnections.erase(current);
mConnections.erase(connection);
mConnectionCount--;
OnConnectionDestroyed(connection);
delete connection;
}
}
////////////////////////////////////////
// process request queue
while (!mQueuedRequests.empty() && (!mActiveMax || mActiveCount < mActiveMax))
{
//Profile profile("Listener::Process (activate queued request)");
QueueNode & node = mQueuedRequests.front();
if (!IsActive())
{
// If not active, discard queued request
if (node.connection)
{
// normal request, internal requests have no connection
node.connection->NotifyDiscardRequest(node.request);
}
DestroyRequest(node.request);
}
else
{
// Move request to active list
if (node.connection)
{
// normal request, internal requests have no connection
node.connection->NotifyBeginRequest(node.request);
}
mActiveRequests.push_back(node);
mActiveCount++;
}
mQueuedRequests.pop_front();
}
////////////////////////////////////////
// Process active requests
unsigned requestsProcessed = 0;
std::list<QueueNode>::iterator iterator = mActiveRequests.begin();
while (iterator != mActiveRequests.end())
{
//Profile profile("Listener::Process (process request)");
std::list<QueueNode>::iterator current = iterator++;
RequestBase * request = current->request;
Connection * connection = current->connection;
if (request->Process())
{
if (connection)
{
// normal request, internal requests have no connection
connection->NotifyEndRequest(request);
}
DestroyRequest(request);
mActiveRequests.erase(current);
mActiveCount--;
}
else if (mSleepingRequests.find(request) != mSleepingRequests.end())
{
mActiveRequests.erase(current);
}
requestsProcessed++;
}
return requestsProcessed;
}