当前位置: 首页>>代码示例>>C++>>正文


C++ ProcessPtr::getGroup方法代码示例

本文整理汇总了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;
	}
}
开发者ID:1234-,项目名称:passenger,代码行数:26,代码来源:ProcessUtils.cpp

示例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;
}
开发者ID:1234-,项目名称:passenger,代码行数:21,代码来源:ProcessUtils.cpp

示例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;
	}
}
开发者ID:1234-,项目名称:passenger,代码行数:22,代码来源:ProcessUtils.cpp

示例4: getProcess

void
Session::requestOOBW() {
	ProcessPtr process = getProcess();
	assert(process->isAlive());
	process->getGroup()->requestOOBW(process);
}
开发者ID:chrisroos,项目名称:passenger,代码行数:6,代码来源:Implementation.cpp

示例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();
		}
	}
}
开发者ID:defanator,项目名称:passenger,代码行数:99,代码来源:Miscellaneous.cpp

示例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();
		}
	}
}
开发者ID:NyawiraNjoroge,项目名称:nt_aws,代码行数:101,代码来源:Miscellaneous.cpp


注:本文中的ProcessPtr::getGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。