Looks like a bug. Would you mind opening an issue on the emscripten tracker? I don't think we do a lot of testing with wasm workers and pthreads combined like that so it's perhaps not surprising.
cheers, sam On Fri, Sep 15, 2023 at 4:19 AM 'Dieter Weidenbrück (dweidenbrueck)' via emscripten-discuss <emscripten-discuss@googlegroups.com> wrote: > Hi, > I am using both pthreads and wasm workers, and I see more workers being > created than necessary. > The reason seems to be the following: > > PThread.init checks for ENVIRONMENT_IS_PTHREAD first, in all other cases > Pthread.initMainThread is called. To me it looks like there should be an > additional check for > ENVIRONMENT_IS_WASM_WORKER: > > init: function() { > PThread.debugInit(); > if (ENVIRONMENT_IS_PTHREAD || ENVIRONMENT_IS_WASM_WORKER) { > PThread.initWorker(); > } else { > PThread.initMainThread(); > } > }, > > The current init function leads to initMainThread being called for each > wasm worker, which in turn will call PThread.init to allocate the number of > workers specified by PTHREAD_POOL_SIZE multiple times.. > It seems to work correctly with the suggested change, however, I am not > familiar enough with the internals of Emscripten to make a judgement. > > -- > 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-discuss+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/c77af58d-f543-4a98-80c5-1a855240e6e2n%40googlegroups.com > <https://groups.google.com/d/msgid/emscripten-discuss/c77af58d-f543-4a98-80c5-1a855240e6e2n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- 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-discuss+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAL_va28m2FhpxG3xgb3yD6hVaDXNUWhFm-7sHxqOTmAi8Ru3Tw%40mail.gmail.com.