Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <title>Single Worker Test</title> | 3 <title>Single Worker Test</title> |
| 4 | 4 |
| 5 <script src="worker_utils.js"></script> | 5 <script src="worker_utils.js"></script> |
| 6 | 6 |
| 7 <script> | 7 <script> |
| 8 var workers = []; | 8 var workers = []; |
| 9 function startAndTerminateWorkers() { | 9 function startAndTerminateWorkers() { |
| 10 var terminateCount = 0; | 10 var terminateCount = 0; |
| 11 for (var i = 0 ; i < 200 ; i++) { | 11 for (var i = 0 ; i < 16 ; i++) { |
| 12 var w = new Worker("worker_common.js"); | 12 var w = new Worker("worker_common.js"); |
| 13 workers.push(w); | 13 workers.push(w); |
| 14 w.postMessage("ping"); | 14 w.postMessage("ping"); |
| 15 w.onmessage = function() { | 15 w.onmessage = function() { |
| 16 terminateCount++; | 16 terminateCount++; |
| 17 if (terminateCount == 16) { | 17 if (terminateCount == 16) { |
| 18 shutdownWorkers(); | 18 shutdownWorkers(); |
| 19 } | 19 } |
| 20 if (terminateCount > 16) { | |
| 21 // Should not get more than 16 messages back unless we raise the worker | |
| 22 // limit. | |
|
Andrew T Wilson (Slow)
2012/03/28 22:44:09
Why did we get rid of this check? Was it race-y?
jam
2012/03/28 23:01:27
now we can run more than 16 workers with isolates
Andrew T Wilson (Slow)
2012/03/28 23:49:27
Note that now this test doesn't actually do much u
jam
2012/03/29 01:03:41
good point. I tried to switch it to a SharedWorker
| |
| 23 onFailure(); | |
| 24 } | |
| 25 } | 20 } |
| 26 } | 21 } |
| 27 } | 22 } |
| 28 | 23 |
| 29 function shutdownWorkers() { | 24 function shutdownWorkers() { |
| 30 for (var i = 0 ; i < workers.length ; i++) { | 25 for (var i = 0 ; i < workers.length ; i++) { |
| 31 workers[i].terminate(); | 26 workers[i].terminate(); |
| 32 } | 27 } |
| 33 workers = []; | 28 workers = []; |
| 34 onSuccess(); | 29 onSuccess(); |
| 35 } | 30 } |
| 36 | 31 |
| 37 startAndTerminateWorkers(); | 32 startAndTerminateWorkers(); |
| 38 </script> | 33 </script> |
| 39 | 34 |
| 40 <body> | 35 <body> |
| 41 <div id=statusPanel></div> | 36 <div id=statusPanel></div> |
| 42 </body> | 37 </body> |
| OLD | NEW |