| 180 | } |
| 181 | |
| 182 | void 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 | |
| 218 | std::string QuickJSRuntime::get_result() |
| 219 | { |
no test coverage detected