| 108 | } |
| 109 | |
| 110 | void ScriptRunner::shutdown(void) |
| 111 | { |
| 112 | if (mState.load() == State::Idle) { |
| 113 | return; |
| 114 | } |
| 115 | |
| 116 | Logging::trace("[script] shutdown: aborting '{}' and reaping the worker", mName); |
| 117 | // requestCancel() is the whole "make it stop" half: abort flag first, then |
| 118 | // cancelAll() so a parked request() returns and every later one refuses to |
| 119 | // park. Without it the wait below (and the platform join after it) would |
| 120 | // never be answered. |
| 121 | requestCancel(); |
| 122 | |
| 123 | // Wait for run() to publish its outcome. It runs past the abort only as far |
| 124 | // as the script's next statement, plus whatever native binding it is inside |
| 125 | // right now — that call has to finish either way before it is safe to tear |
| 126 | // down the services underneath it. |
| 127 | std::unique_lock<std::mutex> lock(mMutex); |
| 128 | mDoneCv.wait(lock, [this] { return mState.load() != State::Running; }); |
| 129 | Logging::trace("[script] shutdown: worker finished"); |
| 130 | } |
| 131 | |
| 132 | bool ScriptRunner::cancelRequested(void) const |
| 133 | { |
nothing calls this directly
no test coverage detected