本文整理汇总了C++中ProcessPtr::getGroup方法的典型用法代码示例。如果您正苦于以下问题:C++ ProcessPtr::getGroup方法的具体用法?C++ ProcessPtr::getGroup怎么用?C++ ProcessPtr::getGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProcessPtr
的用法示例。
在下文中一共展示了ProcessPtr::getGroup方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: l
DisableResult
Pool::disableProcess(const StaticString &gupid) {
ScopedLock l(syncher);
ProcessPtr process = findProcessByGupid(gupid, false);
if (process != NULL) {
Group *group = process->getGroup();
// Must be a boost::shared_ptr to be interruption-safe.
boost::shared_ptr<DisableWaitTicket> ticket = boost::make_shared<DisableWaitTicket>();
DisableResult result = group->disable(process,
boost::bind(syncDisableProcessCallback, _1, _2, ticket));
group->verifyInvariants();
group->verifyExpensiveInvariants();
if (result == DR_DEFERRED) {
l.unlock();
ScopedLock l2(ticket->syncher);
while (!ticket->done) {
ticket->cond.wait(l2);
}
return ticket->result;
} else {
return result;
}
} else {
return DR_NOOP;
}
}
示例2: findOldestIdleProcess
/**
* Calls Group::detach() so be sure to fix up the invariants afterwards.
* See the comments for Group::detach() and the code for detachProcessUnlocked().
*/
ProcessPtr
Pool::forceFreeCapacity(const Group *exclude,
boost::container::vector<Callback> &postLockActions)
{
ProcessPtr process = findOldestIdleProcess(exclude);
if (process != NULL) {
P_DEBUG("Forcefully detaching process " << process->inspect() <<
" in order to free capacity in the pool");
Group *group = process->getGroup();
assert(group != NULL);
assert(group->getWaitlist.empty());
group->detach(process, postLockActions);
}
return process;
}
示例3:
bool
Pool::detachProcessUnlocked(const ProcessPtr &process,
boost::container::vector<Callback> &postLockActions)
{
if (OXT_LIKELY(process->isAlive())) {
verifyInvariants();
Group *group = process->getGroup();
group->detach(process, postLockActions);
// 'process' may now be a stale pointer so don't use it anymore.
assignSessionsToGetWaiters(postLockActions);
possiblySpawnMoreProcessesForExistingGroups();
group->verifyInvariants();
verifyInvariants();
verifyExpensiveInvariants();
return true;
} else {
return false;
}
}
示例4: getProcess
void
Session::requestOOBW() {
ProcessPtr process = getProcess();
assert(process->isAlive());
process->getGroup()->requestOOBW(process);
}
示例5: lock
// 'lockNow == false' may only be used during unit tests. Normally we
// should never call the callback while holding the lock.
void
Pool::asyncGet(const Options &options, const GetCallback &callback, bool lockNow) {
DynamicScopedLock lock(syncher, lockNow);
assert(lifeStatus == ALIVE || lifeStatus == PREPARED_FOR_SHUTDOWN);
verifyInvariants();
P_TRACE(2, "asyncGet(appGroupName=" << options.getAppGroupName() << ")");
boost::container::vector<Callback> actions;
Group *existingGroup = findMatchingGroup(options);
if (OXT_LIKELY(existingGroup != NULL)) {
/* Best case: the app group is already in the pool. Let's use it. */
P_TRACE(2, "Found existing Group");
existingGroup->verifyInvariants();
SessionPtr session = existingGroup->get(options, callback, actions);
existingGroup->verifyInvariants();
verifyInvariants();
P_TRACE(2, "asyncGet() finished");
if (lockNow) {
lock.unlock();
}
if (session != NULL) {
callback(session, ExceptionPtr());
}
} else if (!atFullCapacityUnlocked()) {
/* The app super group isn't in the pool and we have enough free
* resources to make a new one.
*/
P_DEBUG("Spawning new Group");
GroupPtr group = createGroupAndAsyncGetFromIt(options,
callback, actions);
group->verifyInvariants();
verifyInvariants();
P_DEBUG("asyncGet() finished");
} else {
/* Uh oh, the app super group isn't in the pool but we don't
* have the resources to make a new one. The sysadmin should
* configure the system to let something like this happen
* as least as possible, but let's try to handle it as well
* as we can.
*/
ProcessPtr freedProcess = forceFreeCapacity(NULL, actions);
if (freedProcess == NULL) {
/* No process is eligible for killing. This could happen if, for example,
* all (super)groups are currently initializing/restarting/spawning/etc.
* We have no choice but to satisfy this get() action later when resources
* become available.
*/
P_DEBUG("Could not free a process; putting request to top-level getWaitlist");
getWaitlist.push_back(GetWaiter(
options.copyAndPersist(),
callback));
} else {
/* Now that a process has been trashed we can create
* the missing Group.
*/
P_DEBUG("Creating new Group");
GroupPtr group = createGroup(options);
SessionPtr session = group->get(options, callback,
actions);
/* The Group is now spawning a process so the callback
* should now have been put on the wait list,
* unless something has changed and we forgot to update
* some code here or if options.noop...
*/
if (session != NULL) {
assert(options.noop);
actions.push_back(boost::bind(GetCallback::call,
callback, session, ExceptionPtr()));
}
freedProcess->getGroup()->verifyInvariants();
group->verifyInvariants();
}
assert(atFullCapacityUnlocked());
verifyInvariants();
verifyExpensiveInvariants();
P_TRACE(2, "asyncGet() finished");
}
if (!actions.empty()) {
if (lockNow) {
if (lock.owns_lock()) {
lock.unlock();
}
runAllActions(actions);
} else {
// This state is not allowed. If we reach
// here then it probably indicates a bug in
// the test suite.
abort();
}
}
}
示例6: lock
//.........这里部分代码省略.........
char message[50];
snprintf(message, 100, "queue: %zu / %s, spawning: %s", existingGroup->getWaitlist.size(),
(queueMax == 0 ? "inf" : queueMaxStr),
(existingGroup->processesBeingSpawned == 0 ? "no" : "yes"));
data["message"] = message;
}
Json::Value json;
json["data"] = data;
json["data_type"] = "generic";
json["name"] = "Await available process";
*stopwatchLog = new UnionStation::StopwatchLog(options.transaction, "Pool::asyncGet", stringifyJson(json).c_str());
}
if (OXT_LIKELY(existingGroup != NULL)) {
/* Best case: the app group is already in the pool. Let's use it. */
P_TRACE(2, "Found existing Group");
existingGroup->verifyInvariants();
SessionPtr session = existingGroup->get(options, callback, actions);
existingGroup->verifyInvariants();
verifyInvariants();
P_TRACE(2, "asyncGet() finished");
if (lockNow) {
lock.unlock();
}
if (session != NULL) {
callback(session, ExceptionPtr());
}
} else if (!atFullCapacityUnlocked()) {
/* The app super group isn't in the pool and we have enough free
* resources to make a new one.
*/
P_DEBUG("Spawning new Group");
GroupPtr group = createGroupAndAsyncGetFromIt(options,
callback, actions);
group->verifyInvariants();
verifyInvariants();
P_DEBUG("asyncGet() finished");
} else {
/* Uh oh, the app super group isn't in the pool but we don't
* have the resources to make a new one. The sysadmin should
* configure the system to let something like this happen
* as least as possible, but let's try to handle it as well
* as we can.
*/
ProcessPtr freedProcess = forceFreeCapacity(NULL, actions);
if (freedProcess == NULL) {
/* No process is eligible for killing. This could happen if, for example,
* all (super)groups are currently initializing/restarting/spawning/etc.
* We have no choice but to satisfy this get() action later when resources
* become available.
*/
P_DEBUG("Could not free a process; putting request to top-level getWaitlist");
getWaitlist.push_back(GetWaiter(
options.copyAndPersist().detachFromUnionStationTransaction(),
callback));
} else {
/* Now that a process has been trashed we can create
* the missing Group.
*/
P_DEBUG("Creating new Group");
GroupPtr group = createGroup(options);
SessionPtr session = group->get(options, callback,
actions);
/* The Group is now spawning a process so the callback
* should now have been put on the wait list,
* unless something has changed and we forgot to update
* some code here or if options.noop...
*/
if (session != NULL) {
assert(options.noop);
actions.push_back(boost::bind(GetCallback::call,
callback, session, ExceptionPtr()));
}
freedProcess->getGroup()->verifyInvariants();
group->verifyInvariants();
}
assert(atFullCapacityUnlocked());
verifyInvariants();
verifyExpensiveInvariants();
P_TRACE(2, "asyncGet() finished");
}
if (!actions.empty()) {
if (lockNow) {
if (lock.owns_lock()) {
lock.unlock();
}
runAllActions(actions);
} else {
// This state is not allowed. If we reach
// here then it probably indicates a bug in
// the test suite.
abort();
}
}
}