@abtnode/util 1.16.25-beta-f9c1b564 → 1.16.25-beta-e3dbef52
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/lib/lock.js +14 -2
- package/package.json +6 -6
package/lib/lock.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const { EventEmitter } = require('events');
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const locks = new Map();
|
|
4
|
+
|
|
5
|
+
class Lock {
|
|
4
6
|
constructor(name) {
|
|
5
7
|
this.name = name;
|
|
6
8
|
this.locked = false;
|
|
@@ -33,4 +35,14 @@ module.exports = class Lock {
|
|
|
33
35
|
this.locked = false;
|
|
34
36
|
setImmediate(() => this.events.emit('release'));
|
|
35
37
|
}
|
|
36
|
-
|
|
38
|
+
|
|
39
|
+
static getLock(name) {
|
|
40
|
+
if (!locks.has(name)) {
|
|
41
|
+
locks.set(name, new Lock(name));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return locks.get(name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
module.exports = Lock;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "1.16.25-beta-
|
|
6
|
+
"version": "1.16.25-beta-e3dbef52",
|
|
7
7
|
"description": "ArcBlock's JavaScript utility",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
9
|
"files": [
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@abtnode/constant": "1.16.25-beta-
|
|
22
|
-
"@abtnode/logger": "1.16.25-beta-
|
|
23
|
-
"@blocklet/constant": "1.16.25-beta-
|
|
24
|
-
"@blocklet/meta": "1.16.25-beta-
|
|
21
|
+
"@abtnode/constant": "1.16.25-beta-e3dbef52",
|
|
22
|
+
"@abtnode/logger": "1.16.25-beta-e3dbef52",
|
|
23
|
+
"@blocklet/constant": "1.16.25-beta-e3dbef52",
|
|
24
|
+
"@blocklet/meta": "1.16.25-beta-e3dbef52",
|
|
25
25
|
"@ocap/client": "1.18.113",
|
|
26
26
|
"@ocap/mcrypto": "1.18.113",
|
|
27
27
|
"@ocap/util": "1.18.113",
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"fs-extra": "^11.2.0",
|
|
77
77
|
"jest": "^29.7.0"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "a740380dd98d1677f7da1233d753f28ea50f77ce"
|
|
80
80
|
}
|