data sharing

37 views
Skip to first unread message

zhiqiang ren

unread,
Feb 23, 2022, 2:21:29 AM2/23/22
to emscripten-discuss
   How can multiple threads access the same wasm data source? For example, the main thread writes data (module.fs.readfile ('File ',' footer ')). I want to access it through the new wasm instance in the worker thread, module1 FS. readFile('file')。

I've seen the proxy mechanism, but it can only be in the same thread, with different new wasm instances

module2. FS. mkdir("/fs1");
module2. FS. mount(module2.PROXYFS, {
root: "/",
fs: module1. FS
}, "/fs1");


Sam Clegg

unread,
Feb 23, 2022, 12:58:58 PM2/23/22
to emscripte...@googlegroups.com
While the native filesystem API (fopen/fclose/fread) etc works from any thread, JS filesystem API (at least the current one, not the new wasmfs one) is designed to run only the main thread.     The native calls are automatically proxied back to the main thread where they execute the JS APIs.   If you are making direct calls to the JS API you need to do it from the main thread.

You can see how/why the syscalls get proxied back to the main thread here:


cheers,
sam

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/5751a37a-b69d-4b32-9bba-0b8a976f4848n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages