This commit is contained in:
msqr1
2024-01-31 22:49:07 -08:00
parent 1b74781a9d
commit 9d21692993
5 changed files with 29 additions and 35 deletions

View File

@@ -1,4 +1,5 @@
#include "global.h"
static pthread_t selfTID{pthread_self()};
void throwJS(const char* msg, bool err) {
EM_ASM({
@@ -13,16 +14,13 @@ void fireEv(const char *type, const char *content, int index) {
static ProxyingQueue pq{};
auto proxy{[index, type, content](){
EM_ASM({
console.log("Event type ", UTF8ToString($1), ", content " , UTF8ToString($2), ", sending to ", objs[$0]);
objs[$0].dispatchEvent(new CustomEvent(UTF8ToString($1), {"detail" : UTF8ToString($2)}));
},index, type, content);
}};
if(selfTID == pthread_self()) {
emscripten_console_log("Self dispatch");
proxy();
return;
}
emscripten_console_log("Thread dispatch");
pq.proxySync(selfTID, proxy);
}