MCPcopy Create free account
hub / github.com/MaaXYZ/MaaFramework / exec_loop

Method exec_loop

source/binding/NodeJS/src/plugin/runtime.cpp:182–216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182void QuickJSRuntime::exec_loop(bool auto_quit)
183{
184 JSContext* unused;
185 while (true) {
186 if (d_->quit) {
187 break;
188 }
189 if (auto_quit && d_->should_quit()) {
190 break;
191 }
192 while (true) {
193 auto state = JS_ExecutePendingJob(d_->rt, &unused);
194 if (!state) {
195 break;
196 }
197 if (state < 0) {
198 std::cerr << "got unhandled exception" << std::endl;
199 d_->quit = true;
200 return;
201 }
202 }
203
204 auto tasks = d_->take_task_callbacks();
205 for (const auto& task : tasks) {
206 task(d_->ctx);
207 }
208
209 if (!JS_IsJobPending(d_->rt)) {
210 d_->wait_task_callback();
211 }
212 }
213
214 d_->wait_running_task();
215 d_->take_task_callbacks();
216}
217
218std::string QuickJSRuntime::get_result()
219{

Callers 1

getRuntimeFunction · 0.80

Calls 4

should_quitMethod · 0.80
take_task_callbacksMethod · 0.80
wait_task_callbackMethod · 0.80
wait_running_taskMethod · 0.80

Tested by

no test coverage detected