aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-04-19 16:46:24 +0800
committerSoopyboo32 <49228220+Soopyboo32@users.noreply.github.com>2022-04-19 16:46:24 +0800
commitb0d6b24e7b916ff63e1de119eecf153eda45540f (patch)
tree1cd423e7e2851f552383c379be28cc16d6bd6d05 /utils
parent70b9ee73274a099cba147e898cd67f26a3944243 (diff)
downloadSoopyV2-b0d6b24e7b916ff63e1de119eecf153eda45540f.tar.gz
SoopyV2-b0d6b24e7b916ff63e1de119eecf153eda45540f.tar.bz2
SoopyV2-b0d6b24e7b916ff63e1de119eecf153eda45540f.zip
+ Score calculations take into account spirit pet
+ Eman boss lazer phase timer
Diffstat (limited to 'utils')
-rw-r--r--utils/networkUtils.js26
-rw-r--r--utils/nonPooledThread.js14
2 files changed, 29 insertions, 11 deletions
diff --git a/utils/networkUtils.js b/utils/networkUtils.js
index fa2cec2..4fad0aa 100644
--- a/utils/networkUtils.js
+++ b/utils/networkUtils.js
@@ -163,9 +163,21 @@ if (!global.networkUtilsThingSoopy) {
let pendingRequests = []
let pendingResolves = []
+ let runningThread = false
register("tick", () => {
- if (pendingRequests.length > 0) {
+ try {
+ while (pendingResolves.length > 0) {
+ let [callback, data] = pendingResolves.shift()
+
+ callback(data)
+ }
+ } catch (e) {
+ console.log(JSON.stringify(e, undefined, 2))
+ }
+
+ if (pendingRequests.length > 0 && !runningThread) {
+ runningThread = true
new Thread(() => {
while (pendingRequests.length > 0) {
let req = pendingRequests.shift()
@@ -178,17 +190,9 @@ if (!global.networkUtilsThingSoopy) {
pendingResolves.push([req.errcallback, e])
}
}
- }).start()
- }
-
- try {
- while (pendingResolves.length > 0) {
- let [callback, data] = pendingResolves.shift()
- callback(data)
- }
- } catch (e) {
- console.log(JSON.stringify(e, undefined, 2))
+ runningThread = false
+ }).start()
}
})
diff --git a/utils/nonPooledThread.js b/utils/nonPooledThread.js
new file mode 100644
index 0000000..2061db1
--- /dev/null
+++ b/utils/nonPooledThread.js
@@ -0,0 +1,14 @@
+let Executors = Java.type("java.util.concurrent.Executors")
+
+class NonPooledThread {
+ constructor(fun) {
+ this.fun = fun
+ this.executor = Executors.newSingleThreadExecutor()
+ }
+
+ start() {
+ this.executor.execute(this.fun)
+ }
+}
+
+export default NonPooledThread \ No newline at end of file