forked from NoCoreNode/node-worker-farm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
30 lines (26 loc) · 679 Bytes
/
index.js
File metadata and controls
30 lines (26 loc) · 679 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
let workerFarm = require('../..');
(async () => {
let workerCount = 0;
let workers = await workerFarm({
maxConcurrentWorkers: 10,
autoStart: true,
onChild(subProcess) {
workerCount++;
return subProcess;
},
asyncInit: true
}, require.resolve('./child'));
let count = 0;
setInterval(() => {
workers(Math.random() * 10, (err, out) => {
if (err) {
return;
}
count++;
console.log(`completed: ${count}`);
if (count === 10) {
// workerFarm.end(workers);
}
})
}, 500);
})();