MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / shutdown

Method shutdown

common/script/scriptrunner.cpp:110–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

108}
109
110void 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
132bool ScriptRunner::cancelRequested(void) const
133{

Callers

nothing calls this directly

Calls 3

traceFunction · 0.85
requestCancelFunction · 0.50
loadMethod · 0.45

Tested by

no test coverage detected