-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,001 additions
and
1 deletion.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
direction: right | ||
|
||
taskQueue: { | ||
grid-columns: 3 | ||
task1 | ||
task2 | ||
task3 | ||
} | ||
|
||
schedule -> taskQueue | ||
|
||
perform: { | ||
hasTask: 还存在任务 { | ||
shape: diamond | ||
} | ||
|
||
peek: peek\n取出优先级最高的任务 | ||
|
||
hasTask -> peek: yes | ||
peek -> execute -> hasTask | ||
} | ||
|
||
taskQueue -> perform.hasTask | ||
perform.hasTask -> end: no |
128 changes: 128 additions & 0 deletions
128
packages/rspress-site/docs/public/d2/mini-scheduler-v1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
direction: right | ||
|
||
taskQueue: { | ||
grid-columns: 3 | ||
task1 | ||
task2 | ||
task3 | ||
} | ||
|
||
schedule -> taskQueue | ||
|
||
schedulePerform: schedulePerform\n(通过宏任务延迟调用 perform) | ||
|
||
perform: { | ||
hasTask: 还存在任务 { | ||
shape: diamond | ||
} | ||
|
||
peek: peek\n取出优先级最高的任务 | ||
|
||
hasTask -> peek: yes | ||
peek -> execute -> hasTask | ||
} | ||
|
||
taskQueue -> schedulePerform -> perform.hasTask | ||
perform.hasTask -> end: no |
129 changes: 129 additions & 0 deletions
129
packages/rspress-site/docs/public/d2/mini-scheduler-v2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
direction: down | ||
*.style: { | ||
border-radius: 8 | ||
} | ||
Queue: { | ||
TimerQueue: TimerQueue(延迟任务队列)\n优先级按照 startTime 排序 { | ||
timer1 -> timer2 -> timer3 | ||
} | ||
|
||
TaskQueue: TaskQueue(立即执行任务队列)\n优先级按照 expirationTime 排序 { | ||
task1 -> task2 -> task3 | ||
} | ||
|
||
shouldDelay: 是否是延迟任务 { | ||
shape: diamond | ||
} | ||
shouldDelay -> TimerQueue: yes | ||
|
||
shouldDelay -> TaskQueue: no | ||
} | ||
|
||
Schedule: { | ||
isFirstTimer: 当前任务是优先级最高的延迟任务\n且不存在立即执行的任务 { | ||
shape: diamond | ||
width: 360 | ||
} | ||
|
||
requestHostTimeout: requestHostTimeout\n(使用 timeout 延迟,之后再次检查任务情况) | ||
|
||
handleTimeout: { | ||
style: { | ||
stroke-dash: 6 | ||
} | ||
advanceTimers: advanceTimers\n(将所有到期的延迟任务移动到TaskQueue中) | ||
|
||
hasDelayTask: TaskQueue存在任务 { | ||
shape: diamond | ||
} | ||
|
||
advanceTimers -> hasDelayTask | ||
} | ||
|
||
schedulePerformWorkUntilDeadline: schedulePerformWorkUntilDeadline\n(通过宏任务延迟调用 performWorkUntilDeadline) | ||
|
||
handleTimeout.hasDelayTask -> requestHostTimeout: no | ||
|
||
handleTimeout.hasDelayTask -> requestHostCallback: yes | ||
|
||
isFirstTimer -> requestHostTimeout: yes | ||
|
||
requestHostTimeout -> handleTimeout | ||
|
||
requestHostCallback -> schedulePerformWorkUntilDeadline | ||
} | ||
|
||
Execution: { | ||
performWorkUntilDeadline -> flushWork -> workLoop.advanceTimers | ||
|
||
workLoop: { | ||
style: { | ||
stroke-dash: 6 | ||
} | ||
advanceTimers: advanceTimers\n(将所有到期的延迟任务移动到TaskQueue中) | ||
|
||
peek: peek\n(从 TaskQueue 中选择优先级最高的任务) | ||
|
||
shouldYield: 立即执行任务已经到期\n并且不需要让出主线程给浏览器 { | ||
shape: diamond | ||
width: 400 | ||
} | ||
|
||
execute: 执行任务 | ||
|
||
finish: 当前任务执行完成 { | ||
shape: diamond | ||
width: 200 | ||
} | ||
|
||
advanceTimers -> peek -> shouldYield | ||
|
||
shouldYield -> execute: yes | ||
|
||
execute -> finish | ||
|
||
finish -> advanceTimers: yes | ||
} | ||
|
||
hasMore: 存在其他立即执行任务 { | ||
shape: diamond | ||
width: 300 | ||
} | ||
|
||
hasMoreDelay: 存在其他延迟任务 { | ||
shape: diamond | ||
width: 300 | ||
} | ||
|
||
workLoop.shouldYield -> hasMore: no | ||
|
||
hasMore -> hasMoreDelay: no | ||
} | ||
|
||
push: push\n(根据优先级生成任务) | ||
|
||
scheduleCallback -> push -> Queue.shouldDelay | ||
|
||
Queue.TimerQueue -> Schedule.isFirstTimer | ||
|
||
Queue.TaskQueue -> Schedule.requestHostCallback | ||
|
||
Schedule.schedulePerformWorkUntilDeadline -> Execution.performWorkUntilDeadline | ||
|
||
Execution.workLoop.finish -> Schedule.schedulePerformWorkUntilDeadline: no | ||
Execution.hasMore -> Schedule.schedulePerformWorkUntilDeadline: yes | ||
|
||
Execution.hasMoreDelay -> Schedule.requestHostTimeout: yes | ||
Execution.hasMoreDelay -> end: no |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters