* @brief Users and applications can choose to have agents always * stop before a particular phase. If all agents have finished * finished running, this routine will check whether they * need to be stepped to a different phase. *********************************************************************/
| 472 | * need to be stepped to a different phase. |
| 473 | *********************************************************************/ |
| 474 | void RunScheduler::CheckStopBeforePhase(egSKIRunType runStepSize) |
| 475 | { |
| 476 | // If we ran by decision and we've run the appropriate number of decisions, |
| 477 | // then step agent until it reached the correct phase where it should stop. |
| 478 | // Just before this point, (end of while loop above) we've checked and fired the |
| 479 | // OutputComplete and OutputGenerated events, so it should be fine to step |
| 480 | // an agent by phases until it gets to StopBefore, and then step the other |
| 481 | // agents in turn. UNLESS we were interrupted. Then we'd need to cross the |
| 482 | // Output-Input Boundary together and generate events... For now, if interrupted, |
| 483 | // or error or halted, we won't do anything here. |
| 484 | |
| 485 | if ((runStepSize == gSKI_RUN_DECISION_CYCLE) && (m_StopBeforePhase != gSKI_INPUT_PHASE)) |
| 486 | { |
| 487 | for (AgentMapIter iter = m_pKernelSML->m_AgentMap.begin() ; iter != m_pKernelSML->m_AgentMap.end() ; iter++) |
| 488 | { |
| 489 | AgentSML* pAgentSML = iter->second ; |
| 490 | gSKI::IAgent* pAgent = pAgentSML->GetIAgent() ; |
| 491 | egSKIPhaseType phase = pAgent->GetCurrentPhase() ; |
| 492 | egSKIRunResult runResult = pAgentSML->GetResultOfLastRun() ; |
| 493 | |
| 494 | while ((phase != m_StopBeforePhase) && (gSKI_RUN_COMPLETED == runResult)) |
| 495 | { |
| 496 | runResult = pAgent->StepInClientThread(gSKI_INTERLEAVE_PHASE, 1) ; |
| 497 | phase = pAgent->GetCurrentPhase() ; |
| 498 | } |
| 499 | // Notify listeners that this agent is finished running |
| 500 | pAgent->FireRunEndsEvent() ; |
| 501 | } |
| 502 | } |
| 503 | } |
| 504 | |
| 505 | /******************************************************************** |
| 506 | * @brief Called when the agent completes a given phase. |
nothing calls this directly
no test coverage detected