本文整理汇总了C++中ProcessPtr::sessionClosed方法的典型用法代码示例。如果您正苦于以下问题:C++ ProcessPtr::sessionClosed方法的具体用法?C++ ProcessPtr::sessionClosed怎么用?C++ ProcessPtr::sessionClosed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProcessPtr
的用法示例。
在下文中一共展示了ProcessPtr::sessionClosed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getPool
void
Group::onSessionClose(const ProcessPtr &process, Session *session) {
TRACE_POINT();
// Standard resource management boilerplate stuff...
PoolPtr pool = getPool();
boost::unique_lock<boost::mutex> lock(pool->syncher);
assert(process->isAlive());
assert(isAlive() || getLifeStatus() == SHUTTING_DOWN);
P_TRACE(2, "Session closed for process " << process->inspect());
verifyInvariants();
UPDATE_TRACE_POINT();
/* Update statistics. */
process->sessionClosed(session);
assert(process->getLifeStatus() == Process::ALIVE);
assert(process->enabled == Process::ENABLED
|| process->enabled == Process::DISABLING
|| process->enabled == Process::DETACHED);
if (process->enabled == Process::ENABLED) {
pqueue.decrease(process->pqHandle, process->busyness());
}
/* This group now has a process that's guaranteed to be not
* totally busy.
*/
assert(!process->isTotallyBusy());
bool detachingBecauseOfMaxRequests = false;
bool detachingBecauseCapacityNeeded = false;
bool shouldDetach =
( detachingBecauseOfMaxRequests = (
options.maxRequests > 0
&& process->processed >= options.maxRequests
)) || (
detachingBecauseCapacityNeeded = (
process->sessions == 0
&& getWaitlist.empty()
&& (
!pool->getWaitlist.empty()
|| anotherGroupIsWaitingForCapacity()
)
)
);
bool shouldDisable =
process->enabled == Process::DISABLING
&& process->sessions == 0
&& enabledCount > 0;
if (shouldDetach || shouldDisable) {
vector<Callback> actions;
if (shouldDetach) {
if (detachingBecauseCapacityNeeded) {
/* Someone might be trying to get() a session for a different
* group that couldn't be spawned because of lack of pool capacity.
* If this group isn't under sufficiently load (as apparent by the
* checked conditions) then now's a good time to detach
* this process or group in order to free capacity.
*/
P_DEBUG("Process " << process->inspect() << " is no longer totally "
"busy; detaching it in order to make room in the pool");
} else {
/* This process has processed its maximum number of requests,
* so we detach it.
*/
P_DEBUG("Process " << process->inspect() <<
" has reached its maximum number of requests (" <<
options.maxRequests << "); detaching it");
}
pool->detachProcessUnlocked(process, actions);
} else {
removeProcessFromList(process, disablingProcesses);
addProcessToList(process, disabledProcesses);
removeFromDisableWaitlist(process, DR_SUCCESS, actions);
maybeInitiateOobw(process);
}
pool->fullVerifyInvariants();
lock.unlock();
runAllActions(actions);
} else {
// This could change process->enabled.
maybeInitiateOobw(process);
if (!getWaitlist.empty() && process->enabled == Process::ENABLED) {
/* If there are clients on this group waiting for a process to
* become available then call them now.
*/
UPDATE_TRACE_POINT();
// Already calls verifyInvariants().
assignSessionsToGetWaitersQuickly(lock);
}
}
}