Strands in JavaScript

Charles Jolley charles at sproutit.com
Thu Oct 8 21:28:14 PDT 2009


Hi,

Sorry if this has been covered already, but I'm curious if this list  
has considered something like co-routines for a future version of ES.   
An example implementation of the concept (I'm not sure of the quality)  
is here:

http://www.xucia.com/strands-doc/index.html

Properly implemented, it seems that co-routines might offer a better  
way to handle concurrency in the browsers than threads or web-workers  
for a number of reasons:

1. Since browser app are essentially event driven, the biggest problem  
with long running calculations in JS is that it block the browser  
event handling.  Co-routines offer an easy way around this as a long  
running task can be stopped and restarted later without losing context.

2. Properly designed, co-routines can form the foundation of a  
scheduling library along the lines of Grand Central Dispatch which  
would ultimately allow a browser engine to pawn off multiple CPU cores.

Most importantly, my experience with co-routines is that it makes  
harder event-driven style of programming to act more straightforward.

-Charles



More information about the es-discuss mailing list