cgserver 6.4.1 → 6.4.2

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.
@@ -10,8 +10,8 @@ class AsyncQueueItem {
10
10
  constructor(key) {
11
11
  this.key = key;
12
12
  }
13
- add(func) {
14
- this.funcs.push(func);
13
+ add(func, cb) {
14
+ this.funcs.push({ func: func, cb: cb });
15
15
  this._run();
16
16
  }
17
17
  async _run() {
@@ -21,17 +21,23 @@ class AsyncQueueItem {
21
21
  this.running = true;
22
22
  while (this.funcs.length > 0) {
23
23
  try {
24
- let func = this.funcs.shift();
25
- if (!func) {
24
+ let funcitem = this.funcs.shift();
25
+ if (!funcitem.func) {
26
26
  continue;
27
27
  }
28
- if (cgserver_1.core.isAsyncFunc(func)) {
29
- await func().catch((error) => {
28
+ if (cgserver_1.core.isAsyncFunc(funcitem.func)) {
29
+ await funcitem.func().catch((error) => {
30
30
  Log_1.GLog.error(error);
31
31
  });
32
+ if (funcitem.cb) {
33
+ funcitem.cb();
34
+ }
32
35
  }
33
36
  else {
34
- func();
37
+ funcitem.func();
38
+ if (funcitem.cb) {
39
+ funcitem.cb();
40
+ }
35
41
  }
36
42
  }
37
43
  catch (error) {
@@ -1,9 +1,12 @@
1
1
  declare class AsyncQueueItem {
2
2
  key: string;
3
3
  running: boolean;
4
- funcs: Function[];
4
+ funcs: {
5
+ func: Function;
6
+ cb?: Function;
7
+ }[];
5
8
  constructor(key: string);
6
- add(func: Function): void;
9
+ add(func: Function, cb?: Function): void;
7
10
  protected _run(): Promise<void>;
8
11
  }
9
12
  declare class AsyncQueueTool {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cgserver",
3
- "version": "6.4.1",
3
+ "version": "6.4.2",
4
4
  "author": "trojan",
5
5
  "type": "commonjs",
6
6
  "description": "free for all.Websocket or Http",