Peter Lee wrote:

> I'm currently making use of xpcom for some transport related things...
> 
> I do the following in the main thread...
> 
> NS_InitXPCOM(&m_serviceManager, binpath);
> 
> Get some services
> rv = m_serviceManager->GetService(kEventQueueServiceCID,
> kEventQueueServiceIID,
>                                      (nsISupports**) &m_eventQService);
> rv = m_eventQService->CreateThreadEventQueue();
> rv = m_serviceManager->GetService(kIOServiceCID, kIOServiceIID,
>                                       (nsISupports**) &m_ioService);
> 
> Next I use IOService to create new channel and do some things... this all
> works so long as it all happens on the main thread.
> 
> However, there are some synchronous operations that might happen on a
> different thread... as soon as I call m_ioService->NewChannel on another
> thread I get assertions about owning thread etc..
> 
> Obviously I can't pass interfaces between threads like this...  So my
> question is what is the right way?  In the COM world I would marshal the
> interface using different api's...  Is there some way in xpcom to marshal
> these interfaces between threads ?
> 
> Insight appreciated,
> 
> -pete
> 

I would argue that necko should be completely threadsafe.  I believe 
that Darin is fielding that question right now in the netlib newsgroup.  
So, if you needed to do a network IO operation on a worker thread, all 
would be fine.

However, most things are not this way now.  For example, if you consumer 
is layout, this data hand-off must happen on the UI event queue.  For 
proxying across threads, you can use the generic nsISupports proxies, or 
you can roll-your-own based on plevents.


Search lxr.mozilla.org for either.

-- 
Doug Turner
[EMAIL PROTECTED]


Reply via email to