void ComposedTask::execute() { if(getCurrentTask()->checkInitialConditions()) { getCurrentTask()->execute(); setState(State::RUNNING); getCurrentTask()->setState(State::RUNNING); } }
void ComposedTask::executePostCompletion() { getCurrentTask()->executePostCompletion(); getCurrentTask()->setState(State::COMPLETED); if(m_taskIndex<m_tasks.size()-1) { //there is another task m_taskIndex++; setState(State::READY); getCurrentTask()->setState(State::READY); }else { //there is no other task setState(State::COMPLETED); getAssignedActor()->setBusy(false); } }
void PathBase::performTask(){ // Calculate the distance from the frame double val=calculateDistanceFunction( getCurrentTask(), true ); // Put the element value in element zero setElementValue( 0, val ); setElementValue( 1, 1.0 ); return; }
void Mapping::mergeDerivatives( const unsigned& ider, const double& df ){ unsigned cur = getCurrentTask(), frameno=ider*getNumberOfReferencePoints() + cur; for(unsigned i=0;i<getNumberOfArguments();++i){ accumulateDerivative( i, df*dfframes[frameno]*mymap->getArgumentDerivative(cur,i) ); } if( getNumberOfAtoms()>0 ){ Vector ader; Tensor tmpvir; tmpvir.zero(); unsigned n=getNumberOfArguments(); for(unsigned i=0;i<getNumberOfAtoms();++i){ ader=mymap->getAtomDerivatives( cur, i ); accumulateDerivative( n, df*dfframes[frameno]*ader[0] ); n++; accumulateDerivative( n, df*dfframes[frameno]*ader[1] ); n++; accumulateDerivative( n, df*dfframes[frameno]*ader[2] ); n++; tmpvir += -1.0*Tensor( getPosition(i), ader ); } Tensor vir; if( !mymap->getVirial( cur, vir ) ) vir=tmpvir; accumulateDerivative( n, df*dfframes[frameno]*vir(0,0) ); n++; accumulateDerivative( n, df*dfframes[frameno]*vir(0,1) ); n++; accumulateDerivative( n, df*dfframes[frameno]*vir(0,2) ); n++; accumulateDerivative( n, df*dfframes[frameno]*vir(1,0) ); n++; accumulateDerivative( n, df*dfframes[frameno]*vir(1,1) ); n++; accumulateDerivative( n, df*dfframes[frameno]*vir(1,2) ); n++; accumulateDerivative( n, df*dfframes[frameno]*vir(2,0) ); n++; accumulateDerivative( n, df*dfframes[frameno]*vir(2,1) ); n++; accumulateDerivative( n, df*dfframes[frameno]*vir(2,2) ); } }
void AdventureScene::addRunningTask() { AdventureTask* runningTaskNewest = getRunningTaskNewest(); if (runningTaskNewest == nullptr || !(runningTaskNewest->wait())) { m_runningTaskList.push_back(getCurrentTask()); m_taskList.pop(); } }
// Make the calling task unsafe from deletion. // This routine removes the calling task's protection from deletion. // Tasks that attempt to delete a protected task will block until the // task is unsafe. When a task becomes unsafe, the deleter will be // unblocked and allowed to delete the task. // The unsafe() primitive utilizes a count to keep track of nested // calls for task protection. When nesting occurs, the task becomes // unsafe only after the outermost unsafe() is executed. OsStatus OsTaskLinux::unsafe(void) { OsTask* pTask; OsStatus res; pTask = getCurrentTask(); res = pTask->mDeleteGuard.releaseRead(); assert(res == OS_SUCCESS); return res; }
void AdventureScene::addRunningTask() { AdventureTask* runningTaskNewest = getRunningTaskNewest(); if (runningTaskNewest == nullptr || !(runningTaskNewest->wait())) { if (!isEnd()) { m_runningTaskList.push_back(getCurrentTask()); m_current++; std::cout << "m_current: " << m_current << std::endl; } } }
// メイン処理 void AdventureScene::update(SceneManager* smgr) { InputManager &idev = InputManager::getInstance(); if (idev.getConfigKeyState(KEY_CANCEL) == 1 && m_backlog.second.size() > 1) smgr->reserveNextScene(new BacklogScene(m_backlog)); // 中断セーブはオミット /*if (idev.getConfigKeyState(KEY_MENU) == 1) { std::vector<std::string> data; data.push_back("scriptpath " + m_scriptPath); data.push_back("current " + std::to_string(m_current - 1)); data.push_back("bg " + getBGKey()); data.push_back("bgm " + getBGMKey()); data.push_back("left " + getLeftCharKey()); data.push_back("right " + getRightCharKey()); ExitDialogScene* dialog = new ExitDialogScene(data); smgr->reserveNextScene(dialog); }*/ if (idev.getConfigKeyState(KEY_LEFT) == 1) { // スキップ処理開始・停止 if (getIsSkipMode()) { setIsSkipMode(false); } else { setIsSkipMode(true); } } if (idev.getConfigKeyState(KEY_RIGHT) == 1) { // 高速スキップ処理 printf("fast skip mode. ==>\n"); setIsSkipMode(true); while (m_taskList.empty() == false) { // スキップの開始 AdventureTask* current = getCurrentTask(); AdventureTask* newest = getRunningTaskNewest(); if ((current != nullptr && typeid(*current) == typeid(ChoiceTask)) || (newest != nullptr && typeid(*newest) == typeid(ChoiceTask)) || (current != nullptr && typeid(*current) == typeid(TransSceneTask)) || (newest != nullptr && typeid(*newest) == typeid(TransSceneTask))) { // 選択肢の入力ではスキップを停止 break; } if (m_taskList.empty() == false) { addRunningTask(); } if (isEnd() && m_runningTaskList.empty()) { break; } runTask(smgr); } setIsSkipMode(false); printf("==> done.\n"); } // 処理するタスクを取得する if (isEnd() && m_runningTaskList.empty()) { smgr->reserveExitScene(); return; } if (m_taskList.empty() == false) { addRunningTask(); } runTask(smgr); }
void MultiColvarBase::performTask(){ // Currently no atoms have derivatives so deactivate those that are active atoms_with_derivatives.deactivateAll(); // Currently no central atoms have derivatives so deactive them all atomsWithCatomDer.deactivateAll(); // Retrieve the atom list if( !setupCurrentAtomList( getCurrentTask() ) ) return; // Do a quick check on the size of this contribution calculateWeight(); // printf("HELLO WEIGHT %f \n",getElementValue(1) ); if( getElementValue(1)<getTolerance() ){ updateActiveAtoms(); return; } // Compute everything double vv=doCalculation(); // Set the value of this element in ActionWithVessel setElementValue( 0, vv ); return; }
static int waitForRingBuffer(RingBuffer *ring,u64 *rflags) { Task *current = getCurrentTask(); WaitQueue wait; /*When we arrive here,the ring->wait.lock is locked and the interrupt is closed.*/ initWaitQueue(&wait,current); addToWaitQueueLocked(&wait,&ring->wait); /*Init the wait queue and add it to ring->wait.*/ current->state = TaskInterruptible; unlockSpinLockRestoreInterrupt(&ring->wait.lock,rflags); schedule(); /*Wait until the ring buffer has data.*/ lockSpinLockCloseInterrupt(&ring->wait.lock,rflags); removeFromWaitQueueLocked(&wait); if(taskSignalPending(current)) /*Interrupted by signals.*/ return -EINTR; return 0; }
void Robot::handleTasks(float dt) { Task *task = getCurrentTask(); if (task == NULL) return; if (!task->isStarted()) { task->onStart(*this, dt); task->setStarted(true); } if (task->onStep(*this, dt) == false) { task->onEnd(*this, dt); delete task; tasks.pop_front(); handleTasks(dt); } }
bool ComposedTask::checkCompletionConditions() { return getCurrentTask()->checkCompletionConditions(); }