Esempio n. 1
0
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());
    }
}
Esempio n. 2
0
//这个错误处理是很麻烦的事情
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");
        }
    }
}