| 27 | #include "scriptuibridge.hpp" |
| 28 | |
| 29 | UiResponse ScriptUiBridge::request(UiRequest req) |
| 30 | { |
| 31 | std::unique_lock<std::mutex> lock(mMutex); |
| 32 | if (mCancelled) { |
| 33 | // Abort in progress: don't park, hand back "cancelled" so the script |
| 34 | // reaches its next statement (where picoc's abort hook fails the run). |
| 35 | return UiResponse{}; |
| 36 | } |
| 37 | mReq = std::move(req); |
| 38 | mTaken = false; |
| 39 | mCv.wait(lock, [this] { return mResp.has_value(); }); |
| 40 | UiResponse out = std::move(*mResp); |
| 41 | mReq.reset(); |
| 42 | mResp.reset(); |
| 43 | mTaken = false; |
| 44 | return out; |
| 45 | } |
| 46 | |
| 47 | void ScriptUiBridge::setStatus(std::string text) |
| 48 | { |
no test coverage detected