void TaskManager::SubmitTasks()
    {
        vector<boost::shared_ptr<ITask> > tasks;
        taskFactory->FillTasks(&tasks);

        vector<ITask*> unownedTasks;
        MemoryUtility::RemoveOwnership(tasks, &unownedTasks);

        int processCount = MpiManager::GetInstance()->GetNumberOfProcesses();
        int currentRank = MpiManager::GetInstance()->GetCurrentRank();

        vector<vector<ITask*> > tasksPerProcess;
        loadBalancer->BalanceTasks(unownedTasks, processCount, &tasksPerProcess);
        vector<ITask*>& currentTasks = tasksPerProcess[currentRank];

        for (vector<ITask*>::iterator it = currentTasks.begin() ; it < currentTasks.end(); it++)
        {
            ITask* task = *it;
            try
            {
                task->Execute();
            }
            catch (Exception& e)
            {
                printf(e.GetMessage().c_str());
            }
            catch (std::exception& e)
            {
                printf(e.what());
            }
            catch (...)
            {
                // TODO: log
            }
        }
    }
예제 #2
0
	/*override*/ task* execute() {
		m_pTask->Execute();
		m_pTask->Release();
		return NULL;
	}