Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Threads and JavaScript
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Expand all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Eric Shepherd  
View profile  
 More options Jul 31 2006, 2:44 pm
Newsgroups: mozilla.dev.tech.xpcom
From: Eric Shepherd <esheph...@mozilla.com>
Date: Mon, 31 Jul 2006 14:44:54 -0400
Local: Mon, Jul 31 2006 2:44 pm
Subject: Threads and JavaScript
I'm preparing to start writing up documentation on how to do  
threading correctly in JavaScript using nsIThread, and could use some  
guidance, since I've not yet actually done it myself.

I'll be experimenting with threads over the next few days so I can  
get a good feeling how they work, but I could use a little help,  
either with answers to these questions or suggestions on places I can  
look for existing information or sample code I an study.

I need to figure out the proper way to communicate between two or  
more threads, as well as how to properly create threads from  
components.  I also need to know what you can and can't access in DOM  
from threads, if anything.

If anyone can point me in the right direction, I'd appreciate it.

Eric Shepherd
Technical Writer
she...@mozilla.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Benjamin Smedberg  
View profile  
 More options Jul 31 2006, 3:14 pm
Newsgroups: mozilla.dev.tech.xpcom
From: Benjamin Smedberg <benja...@smedbergs.us>
Date: Mon, 31 Jul 2006 15:14:52 -0400
Local: Mon, Jul 31 2006 3:14 pm
Subject: Re: Threads and JavaScript

Eric Shepherd wrote:
> I'm preparing to start writing up documentation on how to do threading
> correctly in JavaScript using nsIThread, and could use some guidance,
> since I've not yet actually done it myself.

I'm surprised you're working on this... I don't know of *anyone* who does
this correctly, and it's almost possible using any of our current codebases
to do it productively.

The only pattern I can think of where threads could be useful in JS today is
worker threads that perform synchronous actions and then fire an event back
to the main thread. There are a couple rules to begin with:

1) Never block the main thread
2) Never access non-threadsafe objects from off the main thread. This
includes almost all XPCOM objects, including all of the DOM.

   This means that you can never do multi-threading from DOM script (because
the global JS object is a DOM object), it can only be attempted from JS
components.

3) actions that are complex or block on network activity can be performed on
worker threads. However, because JS does not have access to any of the
"ordinary" threading primitives like locks, monitors, etc. the results of
such actions can only be sent back to the main thread through events. In
fact, after a thread has been created events (or XPCOM proxies, which are
wrappers around events) are basically the only way to communicate back and
forth between threads.

I think that you might do well to document XPCOM proxies first, and then go
back and document threading in general. XPCOM proxies are much more likely
to be used by general code.

--BDS


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Christian Biesinger  
View profile  
 More options Aug 1 2006, 12:49 am
Newsgroups: mozilla.dev.tech.xpcom
From: Christian Biesinger <cbiesin...@web.de>
Date: Mon, 31 Jul 2006 21:49:06 -0700
Local: Tues, Aug 1 2006 12:49 am
Subject: Re: Threads and JavaScript

Benjamin Smedberg wrote:
> I think that you might do well to document XPCOM proxies first, and then
> go back and document threading in general. XPCOM proxies are much more
> likely to be used by general code.

Note that there is some XPCOM proxy documentation at
http://www.mozilla.org/projects/xpcom/Proxies.html

But that's C++ and possibly slightly outdated.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »