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

Task queues decoupled from a thread

0 views
Skip to first unread message

Henri Sivonen

unread,
Nov 9, 2009, 9:12:46 AM11/9/09
to
I was reading about Grand Central Dispatch and thought that the
off-the-main-thread parsing setup in the HTML5 parser could use
something similar.

The off-the-main-thread part of a parser instance needs an
nsIEventTarget that runs the runnables posted to it in the order they
were posted and without starting the next one before the previous one
has finished.

nsIThreadPool doesn't appear to provide this kind of nsIEventTarget.
nsIThread provides this. However, it's undesirable to have a new thread
per parser. Currently (not landed but in my mq), the HTML5 parser simply
uses one nsIThread for all parser instances. Since the
off-the-main-thread part of the parser now consumes its available data
to completion, this means that when a speculation fails, other parsers
don't get served until the stream is reconsumed.

It would be desirable for each parser instance to have a task queue and
then have an automatically sized thread pool where an available thread
would dequeue a runnable from a queue on a ready list and take the queue
off the ready list of queues (to prevent another thread from dequeing
the next runnable from the queue while the previous one is still
running). Once the runnable has finished, the queue would be put back on
the ready list.

Has this sort of thing been considered?

--
Henri Sivonen
hsiv...@iki.fi
http://hsivonen.iki.fi/

0 new messages