本文整理汇总了C++中ProcessPtr类的典型用法代码示例。如果您正苦于以下问题:C++ ProcessPtr类的具体用法?C++ ProcessPtr怎么用?C++ ProcessPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProcessPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: do_procs
static int do_procs(SnapshotPtr &snap, char *args[])
{
list<ProcessPtr> procs;
list<ProcessPtr>::iterator it;
procs = snap->procs();
Sizes::scale_kbytes();
cout << "PID";
for (int i = 0; i < Sizes::NUM_SIZES; ++i) {
cout << "\t" << Sizes::size_name(i);
}
cout << "\t" << "CMD";
cout << "\n";
for (it = procs.begin(); it != procs.end(); ++it) {
ProcessPtr proc = *it;
SizesPtr sizes = proc->sizes();
cout << proc->pid();
for (int i = 0; i < Sizes::NUM_SIZES; ++i) {
cout << "\t" << sizes->sval(i);
}
cout << "\t" << proc->cmdline();
cout << "\n";
}
return 0;
}
示例2: 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;
}
}
示例3: g_it
ProcessPtr
Pool::findOldestIdleProcess(const Group *exclude) const {
ProcessPtr oldestIdleProcess;
GroupMap::ConstIterator g_it(groups);
while (*g_it != NULL) {
const GroupPtr &group = g_it.getValue();
if (group.get() == exclude) {
g_it.next();
continue;
}
const ProcessList &processes = group->enabledProcesses;
ProcessList::const_iterator p_it, p_end = processes.end();
for (p_it = processes.begin(); p_it != p_end; p_it++) {
const ProcessPtr process = *p_it;
if (process->busyness() == 0
&& (oldestIdleProcess == NULL
|| process->lastUsed < oldestIdleProcess->lastUsed)
) {
oldestIdleProcess = process;
}
}
g_it.next();
}
return oldestIdleProcess;
}
示例4: lock
ProcessPtr DatabaseSubsystem::getProcess(int processID)
{
RWLock::ScopedLock lock(_dbLock);
ProcessPtr result;
Session session = getSession();
session << "SELECT * FROM process WHERE process_id = ?",
use(processID), into(result), now;
if (!result.isNull())
getProcessParams(session, result);
return result;
}
示例5: name
SizesPtr File::sizes()
{
if (_procs.empty()) {
warn << "File::sizes - no processes for file " << name() << "\n";
SizesPtr null_sizes;
return null_sizes;
}
// std::set doesn't have .front
ProcessPtr proc = *(_procs.begin());
// This goes over all procs (because of the _maps), the proc is
// we're only using the proc to get to the pagepool.
return Map::sum_sizes(proc->page_pool(), _maps);
}
示例6: oobwAllowed
bool
Group::shouldInitiateOobw(const ProcessPtr &process) const {
return process->oobwStatus == Process::OOBW_REQUESTED
&& process->enabled != Process::DETACHED
&& process->isAlive()
&& oobwAllowed();
}
示例7: run
bool ExeExcuter::run(
const OJString & exeFile,
const OJString & inputFile,
const OJString & outputFile,
OJInt32_t limitTime,
OJInt32_t limitMemory
)
{
ProcessPtr wp = ProcessFactory::create(ProcessType::WithUser, inputFile, outputFile);
wp->create(exeFile, limitTime, limitMemory);
result_ = wp->getExitCodeEx();
runTime_ = wp->getRunTime();
runMemory_ = wp->getRunMemory();
return isAccept();
}
示例8: 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;
}
示例9: ProcessPtr
// ProcessManager::tick
// - run through the list of processes and update them
//
void ProcessManager::tick(uint64_t deltaMilliseconds)
{
ProcessPtr next;
ProcessList::iterator i = m_processList.begin();
for (; i != m_processList.end(); i++)
{
ProcessPtr p = ProcessPtr(*i);
if ( p->isDead() )
{
// Check for a child process and add if exists
next = p->getNext();
if ( next )
{
p->setNext(ProcessPtr((Process *)NULL));
attach( next );
}
detach( p );
}
else if ( p->isActive() && !p->isPaused() )
{
p->update(deltaMilliseconds);
}
}
}
示例10: getPool
void
Group::requestOOBW(const ProcessPtr &process) {
// Standard resource management boilerplate stuff...
PoolPtr pool = getPool();
boost::unique_lock<boost::mutex> lock(pool->syncher);
if (isAlive() && process->isAlive() && process->oobwStatus == Process::OOBW_NOT_ACTIVE) {
process->oobwStatus = Process::OOBW_REQUESTED;
}
}
示例11: disable
void
Group::initiateOobw(const ProcessPtr &process) {
assert(process->oobwStatus == Process::OOBW_REQUESTED);
process->oobwStatus = Process::OOBW_IN_PROGRESS;
if (process->enabled == Process::ENABLED
|| process->enabled == Process::DISABLING)
{
// We want the process to be disabled. However, disabling a process is potentially
// asynchronous, so we pass a callback which will re-aquire the lock and call this
// method again.
P_DEBUG("Disabling process " << process->inspect() << " in preparation for OOBW");
DisableResult result = disable(process,
boost::bind(&Group::lockAndMaybeInitiateOobw, this,
_1, _2, shared_from_this()));
switch (result) {
case DR_SUCCESS:
// Continue code flow.
break;
case DR_DEFERRED:
// lockAndMaybeInitiateOobw() will eventually be called.
return;
case DR_ERROR:
case DR_NOOP:
P_DEBUG("Out-of-band work for process " << process->inspect() << " aborted "
"because the process could not be disabled");
process->oobwStatus = Process::OOBW_NOT_ACTIVE;
return;
default:
P_BUG("Unexpected disable() result " << result);
}
}
assert(process->enabled == Process::DISABLED);
assert(process->sessions == 0);
P_DEBUG("Initiating OOBW request for process " << process->inspect());
interruptableThreads.create_thread(
boost::bind(&Group::spawnThreadOOBWRequest, this, shared_from_this(), process),
"OOBW request thread for process " + process->inspect(),
POOL_HELPER_THREAD_STACK_SIZE);
}
示例12: FormatString
void JavaExcuter::run(
const OJString & exeFile,
const OJString & inputFile,
const OJString & outputFile,
OJInt32_t limitTime,
OJInt32_t limitMemory
)
{
OJString exePath = FileTool::GetFilePath(exeFile);
OJString exeFileName = FileTool::GetFileName(exeFile);//get only name
OJString cmdBuffer;
FormatString(cmdBuffer, OJStr("java -cp %s %s"), exePath.c_str(), exeFileName.c_str());
ProcessPtr wp = ProcessFactory::create(ProcessType::Excuter, inputFile, outputFile);
wp->create(cmdBuffer, limitTime*30, limitMemory*10);
result_ = wp->getResult();
runTime_ = wp->getRunTime();
runMemory_ = wp->getRunMemory();
}
示例13:
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;
}
}
示例14: setProcessParameters
void FTTask::setProcessParameters(ProcessPtr process) const
{
process->setWindowFunction(_windowFunction);
process->setOverlap(_overlap);
process->setWindowSize(_windowSize);
process->parameters["transformCount"] =
Poco::NumberFormatter::format(_transforms.size());
int trIndex = 1;
for (vector<MatrixTransform*>::const_iterator it = _transforms.begin();
it != _transforms.end(); ++it, ++trIndex)
{
string paramName = "transform" + Poco::NumberFormatter::format(trIndex);
process->parameters[paramName] = (*it)->name();
MatrixTransform::TransformParameters tp = (*it)->getParameters();
for (MatrixTransform::TransformParameters::const_iterator
pit = tp.begin(); pit != tp.end(); ++pit)
{
string tparamName = paramName + pit->first;
process->parameters[tparamName] = pit->second;
}
}
}
示例15: ri
// The 'self' parameter is for keeping the current Group object alive while this thread is running.
void
Group::spawnThreadOOBWRequest(GroupPtr self, ProcessPtr process) {
TRACE_POINT();
this_thread::disable_interruption di;
this_thread::disable_syscall_interruption dsi;
Socket *socket;
Connection connection;
PoolPtr pool = getPool();
Pool::DebugSupportPtr debug = pool->debugSupport;
UPDATE_TRACE_POINT();
P_DEBUG("Performing OOBW request for process " << process->inspect());
if (debug != NULL && debug->oobw) {
debug->debugger->send("OOBW request about to start");
debug->messages->recv("Proceed with OOBW request");
}
UPDATE_TRACE_POINT();
{
// Standard resource management boilerplate stuff...
boost::unique_lock<boost::mutex> lock(pool->syncher);
if (OXT_UNLIKELY(!process->isAlive()
|| process->enabled == Process::DETACHED
|| !isAlive()))
{
return;
}
if (process->enabled != Process::DISABLED) {
UPDATE_TRACE_POINT();
P_INFO("Out-of-Band Work canceled: process " << process->inspect() <<
" was concurrently re-enabled.");
if (debug != NULL && debug->oobw) {
debug->debugger->send("OOBW request canceled");
}
return;
}
assert(process->oobwStatus == Process::OOBW_IN_PROGRESS);
assert(process->sessions == 0);
socket = process->sessionSockets.top();
assert(socket != NULL);
}
UPDATE_TRACE_POINT();
unsigned long long timeout = 1000 * 1000 * 60; // 1 min
try {
this_thread::restore_interruption ri(di);
this_thread::restore_syscall_interruption rsi(dsi);
// Grab a connection. The connection is marked as fail in order to
// ensure it is closed / recycled after this request (otherwise we'd
// need to completely read the response).
connection = socket->checkoutConnection();
connection.fail = true;
ScopeGuard guard(boost::bind(&Socket::checkinConnection, socket, connection));
// This is copied from RequestHandler when it is sending data using the
// "session" protocol.
char sizeField[sizeof(uint32_t)];
SmallVector<StaticString, 10> data;
data.push_back(StaticString(sizeField, sizeof(uint32_t)));
data.push_back(makeStaticStringWithNull("REQUEST_METHOD"));
data.push_back(makeStaticStringWithNull("OOBW"));
data.push_back(makeStaticStringWithNull("PASSENGER_CONNECT_PASSWORD"));
data.push_back(makeStaticStringWithNull(process->connectPassword));
uint32_t dataSize = 0;
for (unsigned int i = 1; i < data.size(); i++) {
dataSize += (uint32_t) data[i].size();
}
Uint32Message::generate(sizeField, dataSize);
gatheredWrite(connection.fd, &data[0], data.size(), &timeout);
// We do not care what the actual response is ... just wait for it.
UPDATE_TRACE_POINT();
waitUntilReadable(connection.fd, &timeout);
} catch (const SystemException &e) {
P_ERROR("*** ERROR: " << e.what() << "\n" << e.backtrace());
} catch (const TimeoutException &e) {
P_ERROR("*** ERROR: " << e.what() << "\n" << e.backtrace());
}
UPDATE_TRACE_POINT();
vector<Callback> actions;
{
// Standard resource management boilerplate stuff...
PoolPtr pool = getPool();
boost::unique_lock<boost::mutex> lock(pool->syncher);
if (OXT_UNLIKELY(!process->isAlive() || !isAlive())) {
return;
}
process->oobwStatus = Process::OOBW_NOT_ACTIVE;
if (process->enabled == Process::DISABLED) {
//.........这里部分代码省略.........