main loop which calls the user JS callbacks */
| 4828 | |
| 4829 | /* main loop which calls the user JS callbacks */ |
| 4830 | int js_std_loop(JSContext *ctx) |
| 4831 | { |
| 4832 | JSRuntime *rt = JS_GetRuntime(ctx); |
| 4833 | JSThreadState *ts = js_get_thread_state(rt); |
| 4834 | JSContext *ctx1; |
| 4835 | int err; |
| 4836 | |
| 4837 | for(;;) { |
| 4838 | /* execute the pending jobs */ |
| 4839 | for(;;) { |
| 4840 | err = JS_ExecutePendingJob(JS_GetRuntime(ctx), &ctx1); |
| 4841 | if (err <= 0) { |
| 4842 | if (err < 0) |
| 4843 | goto done; |
| 4844 | break; |
| 4845 | } |
| 4846 | } |
| 4847 | |
| 4848 | js_std_promise_rejection_check(ctx); |
| 4849 | |
| 4850 | if (!ts->can_js_os_poll || js_os_poll(ctx)) |
| 4851 | break; |
| 4852 | } |
| 4853 | done: |
| 4854 | return JS_HasException(ctx); |
| 4855 | } |
| 4856 | |
| 4857 | int js_std_loop_once(JSContext *ctx) |
| 4858 | { |