🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113

This commit is contained in:
Liang Ding 2023-01-20 00:24:40 +08:00
parent 71a8c4e31b
commit 89fd4d9264
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 12 additions and 9 deletions

View file

@ -111,6 +111,11 @@ const (
func Loop() {
for {
time.Sleep(10 * time.Millisecond)
if QueueStatusClosing == taskQueueStatus {
clearQueue()
break
}
task := popTask()
if nil == task {
continue
@ -121,9 +126,6 @@ func Loop() {
}
func CloseWait() {
queueLock.Lock()
defer queueLock.Unlock()
taskQueueStatus = QueueStatusClosing
for {
time.Sleep(10 * time.Millisecond)
@ -133,6 +135,13 @@ func CloseWait() {
}
}
func clearQueue() {
queueLock.Lock()
defer queueLock.Unlock()
taskQueue = []*Task{}
}
func popTask() (ret *Task) {
queueLock.Lock()
defer queueLock.Unlock()