Ver código fonte

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

Liang Ding 2 anos atrás
pai
commit
89fd4d9264
2 arquivos alterados com 12 adições e 9 exclusões
  1. 0 6
      kernel/model/conf.go
  2. 12 3
      kernel/task/queue.go

+ 0 - 6
kernel/model/conf.go

@@ -406,12 +406,6 @@ func Close(force bool, execInstallPkg int) (exitCode int) {
 		}
 	}
 
-	//util.UIProcessIDs.Range(func(key, _ interface{}) bool {
-	//	pid := key.(string)
-	//	util.Kill(pid)
-	//	return true
-	//})
-
 	waitSecondForExecInstallPkg := false
 	if !skipNewVerInstallPkg() {
 		newVerInstallPkgPath := getNewVerInstallPkgPath()

+ 12 - 3
kernel/task/queue.go

@@ -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()