Skip to content

Commit 9814fa4

Browse files
committed
CR
1 parent 44995e2 commit 9814fa4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

system/lib/pthread/proxying.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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

412415
static 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+
}

0 commit comments

Comments
 (0)