The `INCOMING_MODULE_JS_API` setting is designed to properties that you set
on the module before its started.   Its not for exporting things.  That is
what the `-sEXPORTED_FUNCTIONS` settings is for.

So you can do `-sEXPORTED_FUNCTIONS=$Pthread` but the members of that
object will still be mangled so it doesn't do what you want.  You could
always work around this by writing a library function that calls
`PThread.terminateAllThreads` and then exporting that function.  However,
as you have guessed, terminateAllThreads should be considered internal, and
I think `exit()` is function you are looking for.   Perhaps there is a bug
where `exit` isn't doing the right thing for you. Could you open a bug if
that isn't doing what you need it to?

On Fri, Sep 8, 2023 at 7:09 PM 'Maksim Ivanov' via emscripten-discuss <
emscripten-discuss@googlegroups.com> wrote:

> I guess one workaround is to inject code that creates a Module.something
> alias via --post-js.
>
> But I'm still wondering whether INCOMING_MODULE_JS_API or something
> similar could provide a more direct way.
>
>
> On Saturday, September 9, 2023 at 3:34:06 AM UTC+2 Maksim Ivanov wrote:
>
>> Hello,
>>
>> Is it possible to preserve PThread.* functions, like
>> "terminateAllThreads", on the Module object when
>> using INCOMING_MODULE_JS_API and --closure?
>>
>> I tried specifying "terminateAllThreads" or "_terminateAllThreads" or
>> "PThread.terminateAllThreads" in -sINCOMING_MODULE_JS_API, however all of
>> the PThread's properties seem to remain mangled.
>>
>> P.S. If these functions aren't intended to be used by client code, then
>> what would be a better way to force-shutdown pthread workers when one wants
>> to dispose of the emscripten module instance? (It's using Embind, so exit()
>> and friends don't seem to help.)
>>
>>
>> Thanks,
>> Maksim
>>
> --
> 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/b93a52d7-a757-4b8d-87d6-a0ace8e3dcd4n%40googlegroups.com
> <https://groups.google.com/d/msgid/emscripten-discuss/b93a52d7-a757-4b8d-87d6-a0ace8e3dcd4n%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_va2-qnK-G%2BBQLL5%2BsGhBs-o-nb%3D-HCntXXjPkTcDSv-UV5A%40mail.gmail.com.

Reply via email to