embedding javascript in c++ code using spidermonkey

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

embedding javascript in c++ code using spidermonkey

Sara
Hi, all
I want to develop mutithreaded C++ code to embed javascript in it using spidermonkey, so it was supposed that when I was building spidermonkey source code, I should build it as thread safety "-DJS_THREADSAFE" OR if I didn't do that I can use it and get the benefit of multithread code and when compiling my application I set the option of building the application as thread safety "-DJS_THREADSAFE" and don't need to rebuild the source code of spidermonkey ?

thank you,
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: embedding javascript in c++ code using spidermonkey

Jason Orendorff-2
On 12/19/13 5:27 PM, Sara wrote:
> Hi, all
> I want to develop mutithreaded C++ code to embed javascript in it using spidermonkey, so it was supposed that when I was building spidermonkey source code, I should build it as thread safety "-DJS_THREADSAFE" OR if I didn't do that I can use it and get the benefit of multithread code and when compiling my application I set the option of building the application as thread safety "-DJS_THREADSAFE" and don't need to rebuild the source code of spidermonkey ?

You must configure SpiderMonkey with --enable-threadsafe.

If you do that, $OBJDIR/dist/include/js-config.h will define:

    #define JS_THREADSAFE 1

And this is included from jsapi.h. So you don't have to build anything
with -DJS_THREADSAFE, just make sure you're #include-ing the right
headers and it will be defined automatically.

Note that each JSRuntime is still basically single-threaded.

-j

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: embedding javascript in c++ code using spidermonkey

Sara
In reply to this post by Sara
On Friday, December 20, 2013 1:46:21 AM UTC+2, Jason Orendorff wrote:

> On 12/19/13 5:27 PM, Sara wrote:
>
> > Hi, all
>
> > I want to develop mutithreaded C++ code to embed javascript in it using spidermonkey, so it was supposed that when I was building spidermonkey source code, I should build it as thread safety "-DJS_THREADSAFE" OR if I didn't do that I can use it and get the benefit of multithread code and when compiling my application I set the option of building the application as thread safety "-DJS_THREADSAFE" and don't need to rebuild the source code of spidermonkey ?
>
>
>
> You must configure SpiderMonkey with --enable-threadsafe.
>
>
>
> If you do that, $OBJDIR/dist/include/js-config.h will define:
>
>
>
>     #define JS_THREADSAFE 1
>
>
>
> And this is included from jsapi.h. So you don't have to build anything
>
> with -DJS_THREADSAFE, just make sure you're #include-ing the right
>
> headers and it will be defined automatically.
>
>
>
> Note that each JSRuntime is still basically single-threaded.
>
>
>
> -j

Thank you, so I don't rebuild the src code and just enable thread safe while compiling my application, right ?
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: embedding javascript in c++ code using spidermonkey

Jason Orendorff-2
On 12/19/13 5:56 PM, Sara wrote:
> Thank you, so I don't rebuild the src code and just enable thread safe
> while compiling my application, right ?

I'm sorry, but I can't tell exactly what you're asking.

When compiling your application, make sure that the headers you're
#include-ing match the libraries you're linking. You don't have to
rebuild SpiderMonkey every time.

-j

_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine
Reply | Threaded
Open this post in threaded view
|

Re: embedding javascript in c++ code using spidermonkey

Sara
In reply to this post by Sara
On Friday, December 20, 2013 2:02:46 AM UTC+2, Jason Orendorff wrote:

> On 12/19/13 5:56 PM, Sara wrote:
>
> > Thank you, so I don't rebuild the src code and just enable thread safe
>
> > while compiling my application, right ?
>
>
>
> I'm sorry, but I can't tell exactly what you're asking.
>
>
>
> When compiling your application, make sure that the headers you're
>
> #include-ing match the libraries you're linking. You don't have to
>
> rebuild SpiderMonkey every time.
>
>
>
> -j

Yes, I understood that I must configure my libraries and .h file and use the appropriate libraries, and i don't need to rebuild spidermonkey even if i didn't build spidermonkey src code with enabling thread safe.
Thank you very much for your help :)  
_______________________________________________
dev-tech-js-engine mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-tech-js-engine