[Project_owners] some questions about xpcom

Davide Carboni dcarboni at crs4.it
Wed Feb 18 19:33:16 EST 2004

Hi, I ve been reading the doc for the last 2 days but some questions 
remain unresolved for me:

a) I wrote my nsIStuff.idl interface and implemented it in JS. But I 
wrote all the code inside a single JS file nsIStuff.js and it became 
quite big. I wonder how is possible to include functions from other js 
files such as the jslib library. I suppose I can implement as many XP 
components as the JS files required but it seems a little boring.

b) It is not clear to me how to implement multi-threaded application. I 
suppose that once a button in the UI invokes the method of an XPCom the 
UI thread is the one that runs the XPCom code. How can I fork a new 
thread in order to perform a background operation without blocking the 
UI? I tryed to do that using in my XPCom the service nsIThread

     threadclass.init(runnable, 1024*512, 1, null, null);

where runnable is a Javascript object {Run:function(){while(...) {}}}

But I got an error message in the console:

!!!!! XPConnect wrapper thread use error...
  XPConnect WrappedNative is being accessed on multiple threads but the 
underlying native xpcom object does not have a nsIClassInfo with the 
'THREADSAFE' flag set
  wrapper: [xpconnect wrapped nsIThread @ 0x83bc748]
  JS call stack...
0 [native frame]
1 pause(millis = 1000) 
    threadclass = [xpconnect wrapped nsIThread @ 0x83bc748]
    this = [object BackstagePass]
    this.runnable = [object Object]
    this.Callback = [function]
    this.startThread = [function]

I hope not that the answer is "stop using Javascript and use C++ 
instead", because it is hard to accept such a change ;)


More information about the Project_owners mailing list