@nxtedition/lib 23.17.15 → 23.17.16
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/app.js +2 -1
- package/fixed-queue.js +1 -1
- package/package.json +1 -1
- package/util/template/index.js +2 -1
- package/yield.js +11 -4
package/app.js
CHANGED
|
@@ -38,6 +38,7 @@ import { isTimeBetween } from './time.js'
|
|
|
38
38
|
import makeUnderPressure from './under-pressure.js'
|
|
39
39
|
import undici from '@nxtedition/undici'
|
|
40
40
|
import { isPrimary } from 'node:cluster'
|
|
41
|
+
import { doYield } from './yield.js'
|
|
41
42
|
|
|
42
43
|
export function makeApp(appConfig, onTerminate) {
|
|
43
44
|
let ds
|
|
@@ -397,7 +398,7 @@ export function makeApp(appConfig, onTerminate) {
|
|
|
397
398
|
{
|
|
398
399
|
userAgent,
|
|
399
400
|
url: isProduction ? 'ws://deepstream:6020/deepstream' : 'ws://127.0.0.1:6020/deepstream',
|
|
400
|
-
schedule: (fn) =>
|
|
401
|
+
schedule: (fn) => doYield(fn),
|
|
401
402
|
},
|
|
402
403
|
appConfig.deepstream,
|
|
403
404
|
config.deepstream,
|
package/fixed-queue.js
CHANGED
package/package.json
CHANGED
package/util/template/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { initSync } from '@swc/wasm-web'
|
|
|
4
4
|
import { makeTemplateCompiler as commonMakeTemplateCompiler } from './index-common.js'
|
|
5
5
|
import { hashSync } from 'hasha'
|
|
6
6
|
import { request } from '@nxtedition/nxt-undici'
|
|
7
|
+
import { doYield } from '../../yield.js'
|
|
7
8
|
|
|
8
9
|
export * from './index-common.js'
|
|
9
10
|
|
|
@@ -28,7 +29,7 @@ export function makeTemplateCompiler({
|
|
|
28
29
|
fetch: (resource, options) =>
|
|
29
30
|
request(resource, options && dispatcher ? { dispatcher, ...options } : defaultOptions),
|
|
30
31
|
...platform,
|
|
31
|
-
schedule: (fn) =>
|
|
32
|
+
schedule: (fn) => doYield(fn),
|
|
32
33
|
},
|
|
33
34
|
})
|
|
34
35
|
}
|
package/yield.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { FixedQueue } from './fixed-queue.js'
|
|
2
2
|
|
|
3
|
-
const yieldQueue = new FixedQueue()
|
|
4
3
|
const yieldSchedule = globalThis.setImmediate ?? ((fn) => setTimeout(fn, 0))
|
|
5
4
|
|
|
5
|
+
let yieldQueue = new FixedQueue()
|
|
6
6
|
let yieldTimeout = 40
|
|
7
7
|
let yieldActive = false
|
|
8
8
|
let yieldScheduled = false
|
|
@@ -62,8 +62,11 @@ function dispatchYield() {
|
|
|
62
62
|
yieldTime = performance.now()
|
|
63
63
|
yieldActive = false
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
const queue = yieldQueue
|
|
66
|
+
yieldQueue = new FixedQueue()
|
|
67
|
+
|
|
68
|
+
while (!queue.isEmpty()) {
|
|
69
|
+
const resolve = queue.shift()
|
|
67
70
|
|
|
68
71
|
resolve(null)
|
|
69
72
|
|
|
@@ -73,5 +76,9 @@ function dispatchYield() {
|
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
if (yieldQueue.isEmpty()) {
|
|
80
|
+
yieldScheduled = false
|
|
81
|
+
} else {
|
|
82
|
+
yieldSchedule(dispatchYield)
|
|
83
|
+
}
|
|
77
84
|
}
|