本文整理汇总了C++中TaskPtr::GetTaskState方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskPtr::GetTaskState方法的具体用法?C++ TaskPtr::GetTaskState怎么用?C++ TaskPtr::GetTaskState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskPtr
的用法示例。
在下文中一共展示了TaskPtr::GetTaskState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PushTask
//根据状态插入到相应队列中
void VC::PushTask(const TaskPtr& task) {
TaskState ts = task->GetTaskState();
assert(ts == TASK_WAIT || ts == TASK_RUN);
if(ts == TASK_WAIT)
m_wait_queue.PushBack(task);
else
m_run_queue.PushBack(task);
}
示例2: RemoveTask
void VC::RemoveTask(const TaskPtr& task) {
//里面有并发控制机制
TaskState ts = task->GetTaskState();
assert(ts == TASK_WAIT || ts == TASK_RUN);
if(ts == TASK_WAIT) {
m_wait_queue.Erase(task->GetId());
} else {
m_run_queue.Erase(task->GetId());
}
}
示例3: KillTask
//这个错误处理是很麻烦的事情
void VC::KillTask(const TaskPtr& task) {
TaskState ts = task->GetTaskState();
assert(ts == TASK_WAIT || ts == TASK_RUN);
if(ts == TASK_WAIT) {
m_wait_queue.Erase(task->GetId());
} else {
try {
string endpoint = task->GetRunOn();
Proxy<WorkerClient> proxy = Rpc<WorkerClient, WorkerClient>::GetProxy(endpoint);
if(proxy().KillTask(task->GetId()) != 0) {
LOG4CPLUS_ERROR(logger, "delete task " << task->GetId() << " failed");
return;
}
m_run_queue.Erase(task->GetId());
} catch (TException &tx) {
LOG4CPLUS_ERROR(logger, "delte task error " << task->GetId() << " failed");
}
}
}
示例4: AddUsedResource
// add m_used_cpu and m_used_memory of group
bool GroupPool::AddUsedResource(const TaskPtr& task_ptr) {
if (task_ptr->GetTaskState() != TASK_WAITING) {
// restart
return true;
}
GroupPtr group_ptr = GetGroupPtr(task_ptr->GetGroupName());
if (!group_ptr) {
LOG4CPLUS_ERROR(logger, "No this group, group name: " << task_ptr->GetGroupName());
return false;
}
double factor = 1.0;
int32_t priority = task_ptr->GetRawPriority();
if (JOB_RAW_PRIO_PRIVILEGE == priority) {
factor = m_privilege_factor;
}
group_ptr->SetUsedCPU(task_ptr->GetNeedCpu() * factor);
group_ptr->SetUsedMemory(task_ptr->GetNeedMemory() * factor);
return true;
}