Eric H. Jung wrote:
Hi,
If I want to use nsIThread in my JS XPCOM component, how should I
guarantee thread safety of the data structures I use? For instance, in
these threads I want to share a RegExp object and execute RegExp.test()
in each thread. If RegExp.test() succeeds, I add some data to a shared
array. Do I need to do anything special to synchronize/lock write access
to these objects; e.g., create critial sections?
In general, nothing in mozilla is threadsafe. There are a few exceptions
to this rule, but only few.
There are several ways to hack around this, you could for example proxy
stuff on the main thread for xpcom objects.
With js objects itself, or the RegExp in particular, no idea. I suggest
to either dig in the code or ask in the jsengine newsgroup on mozilla.org.
I wouldn't bet money on creating a copy per thread working either, as it
may still be using static vars inside the matching function.
Axel
_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners