multi-tasks 1.2.4 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ multiTasks({
|
|
|
43
43
|
processTask,
|
|
44
44
|
multi_task_parent_folder: `C:/tmp-demo`, //a directory to store progress and results files, you can check the progress here
|
|
45
45
|
quotaOfEachTask:1, //The number of subtasks assigned to each worker at one time, the default is 1
|
|
46
|
-
|
|
46
|
+
numberOfWorkers: 6 //Assign how many workers are working in parallel, default is the number of cpu cores minus one
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
```
|
|
@@ -58,7 +58,7 @@ let RunnerConsumer;//See examples, please provide a Consumer class to process a
|
|
|
58
58
|
master.start(RunnerProducer, RunnerConsumer, {
|
|
59
59
|
multi_task_parent_folder: `C:/tmp-demo`,
|
|
60
60
|
quotaOfEachTask:2, //The number of tasks assigned to each worker
|
|
61
|
-
|
|
61
|
+
numberOfWorkers: 6
|
|
62
62
|
});
|
|
63
63
|
```
|
|
64
64
|
|
|
@@ -71,7 +71,8 @@ node examples/example1/run
|
|
|
71
71
|
|
|
72
72
|
Changelog:
|
|
73
73
|
|
|
74
|
-
- 1.2.
|
|
74
|
+
- 1.2.5 Rename numberOfWorks to numberOfWorkers, the old one are still supported ;-)
|
|
75
|
+
- 1.2.4 Fix: opt.numberOfWorkers not work
|
|
75
76
|
- 1.2.3 Update README
|
|
76
77
|
- 1.2.2 Update README and examples
|
|
77
78
|
- 1.2.1 Handle exceptions and errors in subtasks
|
package/examples/example0/run.js
CHANGED
|
@@ -31,5 +31,5 @@ multiTasks({
|
|
|
31
31
|
processTask,
|
|
32
32
|
multi_task_parent_folder: `C:/tmp-demo`, //a directory to store progress and results files, you can check the progress here
|
|
33
33
|
quotaOfEachTask:1, //The number of subtasks assigned to each worker at one time, the default is 1
|
|
34
|
-
|
|
34
|
+
numberOfWorkers: 6 //Assign how many workers are working in parallel
|
|
35
35
|
});
|
package/examples/example1/run.js
CHANGED
package/examples/example2/run.js
CHANGED
package/package.json
CHANGED
package/workers/master.js
CHANGED
|
@@ -41,7 +41,8 @@ let run = (currentProducer, currentConsumer, opt)=>{
|
|
|
41
41
|
if(typeof opt === 'undefined') opt = {};
|
|
42
42
|
let masterId = currentProducer.getTaskName();
|
|
43
43
|
if(typeof opt.quotaOfEachTask === 'undefined') opt.quotaOfEachTask = 1;
|
|
44
|
-
if(
|
|
44
|
+
if(opt.numberOfWorks && !opt.numberOfWorkers) opt.numberOfWorkers = opt.numberOfWorks; //Backward compatible with the wrong variable name
|
|
45
|
+
if(typeof opt.numberOfWorkers === 'undefined') opt.numberOfWorkers = defaultCPUs;
|
|
45
46
|
console.log('master1, masterId=', masterId)
|
|
46
47
|
|
|
47
48
|
|
|
@@ -50,7 +51,7 @@ let run = (currentProducer, currentConsumer, opt)=>{
|
|
|
50
51
|
console.log('start', getDateTimeTxt())
|
|
51
52
|
|
|
52
53
|
if (cluster.isMaster) {//init
|
|
53
|
-
let numWorks = opt.
|
|
54
|
+
let numWorks = opt.numberOfWorkers;
|
|
54
55
|
console.log(`numCPUs ${numCPUs}`);
|
|
55
56
|
console.log(`numWorks ${numWorks}`);
|
|
56
57
|
console.log(`Master=${process.pid}`);
|