Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

threaded IO not working?

2 views
Skip to first unread message

Mete Ciragan

unread,
Mar 2, 2006, 6:16:50 AM3/2/06
to
I'm writing a Mozilla plugin with the Gecko SDK. It's rendering terrain and
pages tiles of the terrain in a separate thread. Now I've read in the test
file (which does not compile)
http://lxr.mozilla.org/mozilla/source/netwerk/test/TestThreadedIO.cpp that
threaded IO won't work. Is it really not possible to download files from
another thread than the main thread? I tried blocking/synchronous and
non-blocking/asynchronous downloads. And they fail either in
nsIEventQueueService::GetThreadEventQueue or nsIChannel::Open. Both return 0
when called from the main thread and 0x80040111 (NS_ERROR_NOT_AVAILABLE,
Returned when an operation can't complete due to an unavailable resource).

Can anyone confirm this, and if not, give an example on how to download
files in a thread other than the main thread?

Thanks in advance and greetings,
Mete Ciragan

---
ViewTec AG
www.viewtec.ch


Benjamin Smedberg

unread,
Mar 2, 2006, 8:11:11 AM3/2/06
to
Mete Ciragan wrote:
> I'm writing a Mozilla plugin with the Gecko SDK. It's rendering terrain and
> pages tiles of the terrain in a separate thread. Now I've read in the test
> file (which does not compile)
> http://lxr.mozilla.org/mozilla/source/netwerk/test/TestThreadedIO.cpp that
> threaded IO won't work. Is it really not possible to download files from
> another thread than the main thread? I tried blocking/synchronous and
> non-blocking/asynchronous downloads. And they fail either in
> nsIEventQueueService::GetThreadEventQueue or nsIChannel::Open. Both return 0
> when called from the main thread and 0x80040111 (NS_ERROR_NOT_AVAILABLE,
> Returned when an operation can't complete due to an unavailable resource).

It is correct: the networking code is designed to be used only from the main
thread. It uses a worker thread model so that the main thread is never blocked.

--BDS

Christian Biesinger

unread,
Mar 2, 2006, 8:19:19 AM3/2/06
to dev-tech...@lists.mozilla.org
Mete Ciragan wrote:
> And they fail either in
> nsIEventQueueService::GetThreadEventQueue or nsIChannel::Open. Both return 0
> when called from the main thread and 0x80040111 (NS_ERROR_NOT_AVAILABLE,
> Returned when an operation can't complete due to an unavailable resource).

You can probably fix this specific issue by creating a monitored thread
event queue via nsIEventQueueService, but...

> Can anyone confirm this, and if not, give an example on how to download
> files in a thread other than the main thread?

...it is correct that channels are not currently designed to be used on
non-main threads, and are not threadsafe. It would be nice to fix that
eventually, but, for now they are main thread only. Sorry.

Darin Fisher

unread,
Mar 2, 2006, 10:23:23 AM3/2/06
to Mete Ciragan, dev-tech...@lists.mozilla.org
You can use nsISocketTransportService from any thread, but nsIChannel
is main thread only.

-Darin

> _______________________________________________
> dev-tech-network mailing list
> dev-tech...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-tech-network
>

0 new messages