本文整理汇总了C++中Process::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ Process::GetId方法的具体用法?C++ Process::GetId怎么用?C++ Process::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::GetId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WaitAll
int ProcessPool::WaitAll() {
// TODO: 完成代码
int ret = 0;
ProcessVec::iterator it = processes.end();
while (it != processes.begin()) {
it --;
Process* process = *it;
if (process->Kill() != 0) {
cout << "ProcessPool wait all failed in waitting process "
<< process->GetId() << endl;
ret = -1;
break;
}
delete process;
it = processes.erase(it);
}
return ret;
}
示例2: KillAll
int ProcessPool::KillAll() {
// TODO: 完成代码
ProcessVec::iterator it = processes.end();
while (it != processes.begin()) {
it --;
Process* process = *it;
if (process->Kill() != 0) {
cout << "ProcessPool kill all failed in killing process "
<< process->GetId() << endl;
cout << errno << endl;
return -1;
}
delete process;
it = processes.erase(it);
}
return 0;
}
示例3: Start
int ProcessPool::Start(int procCount, Runnable& target) {
//XXX
// 去掉清空,可以支持一个进程池,执行多个任务
// processes.resize(procCount);
for(int i = 0; i < procCount; i++){
Process* tmpProcess = new Process(target);
tmpProcess->SetId(fork());
/*
if (processes[i]->GetId() < 0){
processes.resize(i);
// XXX
// 只能创建那么多
return i;
}
*/
if (tmpProcess->GetId() == 0){
tmpProcess->Start();
exit(0);
}
processes.push_back(tmpProcess);
}
return 0;
}
示例4: checkExit
static void checkExit (int messaging_result_code)
{
if (messaging_result_code == -ERROR_EXITING)
{
Process * process = THREAD_CURRENT()->process;
process->LookupConnection(PROCMGR_CONNECTION_ID)->SendMessageAsync(PULSE_TYPE_CHILD_FINISH, process->GetId());
Thread::BeginTransaction();
Thread::MakeUnready(THREAD_CURRENT(), Thread::STATE_FINISHED);
Thread::RunNextThread();
Thread::EndTransaction();
assert(false);
}
}