|
@@ -26,7 +26,6 @@ function workLoop() {
|
|
} else {
|
|
} else {
|
|
thread.pause();
|
|
thread.pause();
|
|
}
|
|
}
|
|
- thread.pause();
|
|
|
|
});
|
|
});
|
|
if (Thread.isAllEmpty()) {
|
|
if (Thread.isAllEmpty()) {
|
|
isLooping = false;
|
|
isLooping = false;
|
|
@@ -81,7 +80,7 @@ class Thread {
|
|
options: ThreadOptions = {
|
|
options: ThreadOptions = {
|
|
priority: 0,
|
|
priority: 0,
|
|
};
|
|
};
|
|
- status: "normal" | "destroyed" = "normal";
|
|
|
|
|
|
+ status: "running" | "destroyed" | "paused" = "paused";
|
|
samePriorityLength = 0;
|
|
samePriorityLength = 0;
|
|
private startTime = 0;
|
|
private startTime = 0;
|
|
|
|
|
|
@@ -92,6 +91,7 @@ class Thread {
|
|
}
|
|
}
|
|
|
|
|
|
start() {
|
|
start() {
|
|
|
|
+ this.status = "running";
|
|
this.startTime = Date.now();
|
|
this.startTime = Date.now();
|
|
if (!isLooping) {
|
|
if (!isLooping) {
|
|
workLoop();
|
|
workLoop();
|
|
@@ -99,6 +99,7 @@ class Thread {
|
|
}
|
|
}
|
|
|
|
|
|
pause() {
|
|
pause() {
|
|
|
|
+ this.status = "paused";
|
|
this.startTime = 0;
|
|
this.startTime = 0;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -122,6 +123,7 @@ class Thread {
|
|
this.runner = undefined;
|
|
this.runner = undefined;
|
|
this.options = undefined;
|
|
this.options = undefined;
|
|
this.taskUnit = undefined;
|
|
this.taskUnit = undefined;
|
|
|
|
+ this.status = "destroyed";
|
|
}
|
|
}
|
|
|
|
|
|
get shouldYield() {
|
|
get shouldYield() {
|