Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parallel programming / Synchronization using JavaScript Web Workers

Are there any synchronization primitives like Barriers, Semaphors, Locks, Monitors, ... available in JavaScript / Web Workers or is there some library available empowering me to make use of such things (I'm thinking of something like java.util.concurrent in Java)?

Do Workers have obscure properties which differentiate them from Threads (can they share memory with the main thread, for example)? Is there some kind of limit how many workers can be spawned (like, for security reasons or something...)? Do I have to take special care of something?

like image 937
scravy Avatar asked Nov 30 '11 22:11

scravy


1 Answers

Web workers don't have a concept of shared memory; all messages that are passed between threads are copied. With that being said, you don't have Barriers, Semaphores, Locks, and Monitors, because you don't need them in the web worker model.

The concept of shared memory was proposed back in Feb 2011 but the status is now wontfix due to developer complexity => https://lists.webkit.org/pipermail/webkit-unassigned/2011-February/287595.html

There is also a nice blurb about web workers here. http://blogs.msdn.com/b/ie/archive/2011/07/01/web-workers-in-ie10-background-javascript-makes-web-apps-faster.aspx

Hope this helps

like image 182
MatthewJ Avatar answered Oct 07 '22 16:10

MatthewJ