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
- numberOfWorks: 6 //Assign how many workers are working in parallel, default is the number of cpu cores minus one
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
- numberOfWorks: 6
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.4 Fix: opt.numberOfWorks not work
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
@@ -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
- numberOfWorks: 6 //Assign how many workers are working in parallel
34
+ numberOfWorkers: 6 //Assign how many workers are working in parallel
35
35
  });
@@ -5,5 +5,5 @@ let master = require('../../index').master;
5
5
  master.start(RunnerProducer, RunnerConsumer, {
6
6
  multi_task_parent_folder: `C:/tmp-demo`,
7
7
  quotaOfEachTask:2, //The number of tasks assigned to each worker
8
- numberOfWorks: 6
8
+ numberOfWorkers: 6
9
9
  });
@@ -19,5 +19,5 @@ producer.setTaskTrunkInfo(taskConfig);
19
19
  consumer.setTaskTrunkInfo(taskConfig)
20
20
  master.run(producer, consumer, {
21
21
  quotaOfEachTask:2,
22
- numberOfWorks: 6
22
+ numberOfWorkers: 6
23
23
  });
@@ -32,5 +32,5 @@ producer.setTaskTrunkInfo(taskConfig);
32
32
  consumer.setTaskTrunkInfo(taskConfig)
33
33
  master.run(producer, consumer, {
34
34
  quotaOfEachTask:1, //<--Lock as one
35
- numberOfWorks:NUMBER_OF_WORKS
35
+ numberOfWorkers:NUMBER_OF_WORKS
36
36
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "multi-tasks",
3
- "version": "1.2.4",
3
+ "version": "1.2.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "directories": {
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(typeof opt.numberOfWorks === 'undefined') opt.numberOfWorks = defaultCPUs;
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.numberOfWorks;
54
+ let numWorks = opt.numberOfWorkers;
54
55
  console.log(`numCPUs ${numCPUs}`);
55
56
  console.log(`numWorks ${numWorks}`);
56
57
  console.log(`Master=${process.pid}`);