mozilla-spidermonkey / spidermonkey-embedding-examples

Documentation and examples for embedding the SpiderMonkey JavaScript / WebAssembly engine in their applications.
Other
197 stars 34 forks source link

worker.cpp example has unresolved dependencies #61

Closed LGoodacre closed 1 year ago

LGoodacre commented 2 years ago

The new worker.cpp example looks great, but unfortunately I can't get it to compile, because the call to pthread_create() is unresolved. I tracked down this function down to mozilla-central/media/ffvpx/compat/w32pthreads.h, but if I include this file, I just get more missing dependencies. Perhaps this is part of the mozilla framework, but not part of Spidermonkey? Ordinarily this would be OK, but since this repository is specifically aimed at Spidermonkey embedders, it seems like a bit of a problem. Is there another way to create those threads? If not, can you provide more instructions for people who have compiled Spidermonkey but nothing else?

LGoodacre commented 2 years ago

@arai-a

arai-a commented 2 years ago

mozilla-central/media/ffvpx/compat/w32pthreads.h is unrelated here, and this is not issue around outside-of-spidermonkey dependency.

pthread is POSIX thread, and it may not be available on windows (except for cygwin etc).

To create threads on windows, you'll need to call Win32 API equivalent or something (_beginthreadex maybe). I'm not sure which one is modern way (my knowledge is from 10+ years ago), but I'll look into making the code windows compatible.

LGoodacre commented 2 years ago

I see. Is it possible to do it with std::async?