@thi.ng/fibers 0.6.30 → 0.6.32
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/CHANGELOG.md +1 -1
- package/csp.js +15 -15
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
package/csp.js
CHANGED
|
@@ -27,14 +27,14 @@ class Channel {
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
read() {
|
|
30
|
-
const
|
|
30
|
+
const chan = this;
|
|
31
31
|
return fiber(function* (ctx) {
|
|
32
|
-
while (
|
|
33
|
-
if (
|
|
34
|
-
const val =
|
|
32
|
+
while (chan.readable()) {
|
|
33
|
+
if (chan.buffer.readable()) {
|
|
34
|
+
const val = chan.buffer.read();
|
|
35
35
|
ctx.logger?.debug("read", val);
|
|
36
36
|
return val;
|
|
37
|
-
} else if (
|
|
37
|
+
} else if (chan.state === STATE_CLOSING) {
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
yield;
|
|
@@ -56,12 +56,12 @@ class Channel {
|
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
58
|
write(val) {
|
|
59
|
-
const
|
|
59
|
+
const chan = this;
|
|
60
60
|
return fiber(function* (ctx) {
|
|
61
|
-
while (
|
|
62
|
-
if (
|
|
61
|
+
while (chan.writable()) {
|
|
62
|
+
if (chan.buffer.writable()) {
|
|
63
63
|
ctx.logger?.debug("write", val);
|
|
64
|
-
|
|
64
|
+
chan.buffer.write(val);
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
yield;
|
|
@@ -79,18 +79,18 @@ class Channel {
|
|
|
79
79
|
* @param wait
|
|
80
80
|
*/
|
|
81
81
|
close(wait = true) {
|
|
82
|
-
const
|
|
82
|
+
const chan = this;
|
|
83
83
|
return fiber(function* (ctx) {
|
|
84
|
-
if (
|
|
84
|
+
if (chan.state >= STATE_CLOSING)
|
|
85
85
|
return;
|
|
86
86
|
if (wait) {
|
|
87
87
|
ctx.logger?.debug("waiting to close...");
|
|
88
|
-
|
|
89
|
-
while (
|
|
88
|
+
chan.state = STATE_CLOSING;
|
|
89
|
+
while (chan.buffer.readable())
|
|
90
90
|
yield;
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
chan.state = STATE_CLOSED;
|
|
93
|
+
chan.buffer.clear();
|
|
94
94
|
ctx.logger?.debug("channel closed");
|
|
95
95
|
}, this.opts);
|
|
96
96
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/fibers",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.32",
|
|
4
4
|
"description": "Process hierarchies & operators for cooperative multitasking",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@thi.ng/api": "^8.9.30",
|
|
40
|
-
"@thi.ng/arrays": "^2.8.
|
|
40
|
+
"@thi.ng/arrays": "^2.8.11",
|
|
41
41
|
"@thi.ng/bench": "^3.5.0",
|
|
42
|
-
"@thi.ng/checks": "^3.5.
|
|
42
|
+
"@thi.ng/checks": "^3.5.4",
|
|
43
43
|
"@thi.ng/errors": "^2.5.1",
|
|
44
44
|
"@thi.ng/idgen": "^2.2.35",
|
|
45
45
|
"@thi.ng/logger": "^3.0.6",
|
|
46
|
-
"@thi.ng/random": "^3.
|
|
46
|
+
"@thi.ng/random": "^3.7.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@microsoft/api-extractor": "^7.42.3",
|
|
@@ -109,5 +109,5 @@
|
|
|
109
109
|
"status": "alpha",
|
|
110
110
|
"year": 2023
|
|
111
111
|
},
|
|
112
|
-
"gitHead": "
|
|
112
|
+
"gitHead": "da965520b2f3f8c259a791e8e8864308be2ba0be\n"
|
|
113
113
|
}
|