| 74 | } |
| 75 | |
| 76 | void ScenarioManager::ThreadRoutine() |
| 77 | { |
| 78 | std::string const scenarioName = m_scenarioData.m_name; |
| 79 | if (m_onStartHandler != nullptr) |
| 80 | m_onStartHandler(scenarioName); |
| 81 | |
| 82 | for (auto const & action : m_scenarioData.m_scenario) |
| 83 | { |
| 84 | // Interrupt scenario if it's necessary. |
| 85 | { |
| 86 | std::lock_guard<std::mutex> lock(m_mutex); |
| 87 | if (m_needInterrupt) |
| 88 | { |
| 89 | m_needInterrupt = false; |
| 90 | break; |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | switch (action->GetType()) |
| 95 | { |
| 96 | case ActionType::CenterViewport: |
| 97 | { |
| 98 | CenterViewportAction * centerViewportAction = static_cast<CenterViewportAction *>(action.get()); |
| 99 | m_frontendRenderer->AddUserEvent(make_unique_dp<SetCenterEvent>( |
| 100 | centerViewportAction->GetCenter(), centerViewportAction->GetZoomLevel(), true /* isAnim */, |
| 101 | false /* trackVisibleViewport */, nullptr /* parallelAnimCreator */)); |
| 102 | break; |
| 103 | } |
| 104 | |
| 105 | case ActionType::WaitForTime: |
| 106 | { |
| 107 | WaitForTimeAction * waitForTimeAction = static_cast<WaitForTimeAction *>(action.get()); |
| 108 | std::this_thread::sleep_for(waitForTimeAction->GetDuration()); |
| 109 | break; |
| 110 | } |
| 111 | |
| 112 | default: LOG(LINFO, ("Unknown action in scenario")); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | ScenarioCallback handler = nullptr; |
| 117 | { |
| 118 | std::lock_guard<std::mutex> lock(m_mutex); |
| 119 | m_scenarioData.m_scenario.clear(); |
| 120 | m_isFinished = true; |
| 121 | if (m_onFinishHandler != nullptr) |
| 122 | { |
| 123 | handler = m_onFinishHandler; |
| 124 | m_onFinishHandler = nullptr; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | if (handler != nullptr) |
| 129 | handler(scenarioName); |
| 130 | } |
| 131 | |
| 132 | void ScenarioManager::InterruptImpl() |
| 133 | { |
nothing calls this directly
no test coverage detected