There's no way to currently have logging services and use xpcom in a
separate thread.

Currently the nsLoggingService::gLoggingService is initialized even before
XPCOM is started. When I attempt to NS_InitXPCOM in a child thread,
nsLoggingService asserts as the owning thread is not the current thread.

At first glance, this may seem logical, however, let me explain what I am
after, and then you might have a better understanding of the situation.

I desire to use the Necko engine as my network engine.  The network traffic
is secondary to the application, and it should all run in the background (on
a child thread simply retrieving urls on an interval basis).  Because the
necko engine uses other services which are not thread safe (namely the
nsCategoryManager and nsAppFileLocationProvider) I must initialize XPCOM
within the same thread that I intend to perform the necko operations.  With
the limitation that nsLoggingService starts up in the main thread, there is
no way to use logging services while running in a child thread.

Is there a way that I can shut down the logging service while still in the
main thread, and then let XPCOM get a new nsLoggingService during
NS_InitXPCOM?

Are there plans to improve this?  Should I file an enhancement bug?

P.S.  Darin, thank's for your help thus far.  The example in
nsAsyncStreamListener was exactly what I needed.

Rick Marvin
(Neoplanet)



Reply via email to