design change

This commit is contained in:
msqr1
2024-01-31 10:40:05 -08:00
parent 4fc670f2b8
commit f7acda0006
14 changed files with 355 additions and 251 deletions

View File

@@ -11,21 +11,27 @@ void throwJS(const char* msg, bool err) {
}
void fireEv(const char *type, const char *content, int index) {
static ProxyingQueue pq{};
static pthread_t selfTID {pthread_self()};
pq.proxySync(selfTID, [&](){
static pthread_t selfTID{pthread_self()};
static auto proxy{[&](){
EM_ASM({
let ev = new CustomEvent(UTF8ToString($1), {"details" : UTF8ToString($2)});
objs[$0].dispatchEvent(ev);
console.log(objs[$0], ev)
console.log(objs[$0]);
objs[$0].dispatchEvent(new CustomEvent(UTF8ToString($1), {"detail" : UTF8ToString($2)}))
},index, type, content);
});
}};
if(selfTID == pthread_self()) {
proxy();
return;
}
pq.proxySync(selfTID, proxy);
}
int main() {
//vosk_set_log_level(-1);
std::thread t{[](){
wasmfs_create_directory("/opfs",0777,wasmfs_create_opfs_backend());
fireEv("_ev", "test", 0);
}};
t.detach();
fireEv("_ev", "test event", 0);
emscripten_exit_with_live_runtime();
}