6.7.0 - Alpha6 - Fine tuning

This commit is contained in:
SuperMonster003
2025-10-01 00:13:00 +08:00
parent 4fe314d301
commit f3e04b9ca2
165 changed files with 2356 additions and 2413 deletions

View File

@@ -1,12 +1,12 @@
(function() {
(function () {
function setReadonlyAttribute(obj, att, value, enumerable) {
enumerable = (enumerable === undefined) ? true : enumerable
enumerable = (enumerable === undefined) ? true : enumerable;
Object.defineProperty(obj, att, {
value,
writable: false,
configurable: true,
enumerable,
})
});
}
function copyInputStream(inputstream, outputstream) {
@@ -17,40 +17,43 @@
}
outputstream.flush();
}
//此对象用于确保在多线程执行异步任务时主线程不会因空闲而停止
// 此对象用于确保在多线程执行异步任务时主线程不会因空闲而停止
function AsyncThreadLock() {
this.lock = threads.lock();
this.tasks = 0;
this.intervalId = null;
}
setReadonlyAttribute(AsyncThreadLock, 'teeFn', function() {
setReadonlyAttribute(AsyncThreadLock, 'teeFn', function () {
this.intervalId = setInterval(() => {
this.lock.lock();
if (this.tasks === 0) {
clearInterval(this.intervalId)
clearInterval(this.intervalId);
this.intervalId = null;
}
this.lock.unlock();
}, 200)
}, false)
}, 200);
}, false);
AsyncThreadLock.prototype.addTask = function() {
AsyncThreadLock.prototype.addTask = function () {
this.lock.lock();
this.tasks++;
if (this.intervalId === null) {
AsyncThreadLock.teeFn.call(this)
AsyncThreadLock.teeFn.call(this);
}
this.lock.unlock();
}
AsyncThreadLock.prototype.removeTask = function() {
};
AsyncThreadLock.prototype.removeTask = function () {
this.lock.lock();
this.tasks--;
this.lock.unlock();
}
};
module.exports = {
setReadonlyAttribute,
copyInputStream,
AsyncThreadLock,
}
})()
};
})();