File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,9 @@ typedef struct proxied_js_func_t {
4444 double * argBuffer ;
4545 double result ;
4646 bool owned ;
47+ // Only used when when the underlying JS function is async and ctx need to be
48+ // resolved on promise end.
49+ // should be NULL if the function is sync.
4750 em_proxying_ctx * ctx ;
4851} proxied_js_func_t ;
4952
@@ -410,6 +413,7 @@ static void call_then_finish_task(em_proxying_ctx* ctx, void* arg) {
410413}
411414
412415static void call_proxied_js_task_with_ctx (em_proxying_ctx * ctx , void * arg ) {
416+ // Stash the context on the proxied_js_func_t argument.
413417 task * t = arg ;
414418 proxied_js_func_t * p = t -> arg ;
415419 p -> ctx = ctx ;
@@ -624,6 +628,7 @@ double _emscripten_run_on_main_thread_js(int func_index,
624628 .numArgs = num_args ,
625629 .argBuffer = buffer ,
626630 .owned = false,
631+ .ctx = NULL ,
627632 };
628633
629634 em_proxying_queue * q = emscripten_proxy_get_system_queue ();
@@ -681,4 +686,4 @@ void _emscripten_proxy_promise_finish(em_proxying_ctx* ctx, void* res) {
681686 proxied_js_func_t * func = (proxied_js_func_t * )t -> arg ;
682687 func -> result = (double )(intptr_t )res ;
683688 emscripten_proxy_finish (ctx );
684- }
689+ }
You can’t perform that action at this time.
0 commit comments