Debian Codegraph @

workerpool/examples/browser/offloadFunctions.html

raw symbols SCIP
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Worker pool in the browser</title>
5
6 <script src="../../dist/workerpool.min.js"></script>
7 </head>
8 <body>
9
10 <script>
11 // create a worker pool
12 var pool = workerpool.pool();
13
14 // create a static function
15 function add(a, b) {
16 return a + b;
17 }
18
19 // offload execution of a function to the worker pool
20 pool.exec(add, [3, 4])
21 .then(function (result) {
22 document.write('Result: ' + result); // outputs 7
23 })
24 .catch(function (err) {
25 document.write('Error: ' + err);
26 });
27
28 </script>
29
30 </body>
31 </html>