mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 15:10:12 +01:00
🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113
This commit is contained in:
parent
801bc69820
commit
7e014cb525
7 changed files with 27 additions and 15 deletions
|
|
@ -486,7 +486,7 @@ func FullReindex() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func fullReindex() {
|
func fullReindex() {
|
||||||
util.PushEndlessProgress(Conf.Language(35))
|
util.PushMsg(Conf.Language(35), 60*1000*10)
|
||||||
WaitForWritingFiles()
|
WaitForWritingFiles()
|
||||||
|
|
||||||
if err := sql.InitDatabase(true); nil != err {
|
if err := sql.InitDatabase(true); nil != err {
|
||||||
|
|
@ -505,7 +505,7 @@ func fullReindex() {
|
||||||
treenode.SaveBlockTree(true)
|
treenode.SaveBlockTree(true)
|
||||||
LoadFlashcards()
|
LoadFlashcards()
|
||||||
|
|
||||||
util.PushEndlessProgress(Conf.Language(58))
|
util.PushMsg(Conf.Language(58), 7000)
|
||||||
go func() {
|
go func() {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
util.ReloadUI()
|
util.ReloadUI()
|
||||||
|
|
|
||||||
|
|
@ -393,6 +393,7 @@ var exitLock = sync.Mutex{}
|
||||||
func Close(force bool, execInstallPkg int) (exitCode int) {
|
func Close(force bool, execInstallPkg int) (exitCode int) {
|
||||||
exitLock.Lock()
|
exitLock.Lock()
|
||||||
defer exitLock.Unlock()
|
defer exitLock.Unlock()
|
||||||
|
util.IsExiting = true
|
||||||
|
|
||||||
logging.LogInfof("exiting kernel [force=%v, execInstallPkg=%d]", force, execInstallPkg)
|
logging.LogInfof("exiting kernel [force=%v, execInstallPkg=%d]", force, execInstallPkg)
|
||||||
util.PushMsg(Conf.Language(95), 10000*60)
|
util.PushMsg(Conf.Language(95), 10000*60)
|
||||||
|
|
|
||||||
|
|
@ -69,8 +69,7 @@ func index(boxID string) {
|
||||||
var treeSize int64
|
var treeSize int64
|
||||||
i := 0
|
i := 0
|
||||||
|
|
||||||
util.PushEndlessProgress(fmt.Sprintf("["+box.Name+"] "+Conf.Language(64), len(files)))
|
util.PushStatusBar(fmt.Sprintf("["+box.Name+"] "+Conf.Language(64), len(files)))
|
||||||
defer util.PushClearProgress()
|
|
||||||
|
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
if file.isdir || !strings.HasSuffix(file.name, ".sy") {
|
if file.isdir || !strings.HasSuffix(file.name, ".sy") {
|
||||||
|
|
@ -101,7 +100,7 @@ func index(boxID string) {
|
||||||
treeSize += file.size
|
treeSize += file.size
|
||||||
treeCount++
|
treeCount++
|
||||||
if 1 < i && 0 == i%64 {
|
if 1 < i && 0 == i%64 {
|
||||||
util.PushEndlessProgress(fmt.Sprintf(Conf.Language(88), i, len(files)-i))
|
util.PushStatusBar(fmt.Sprintf(Conf.Language(88), i, len(files)-i))
|
||||||
}
|
}
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -104,6 +104,10 @@ func FlushQueue() {
|
||||||
|
|
||||||
context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
|
context := map[string]interface{}{eventbus.CtxPushMsg: eventbus.CtxPushMsgToStatusBar}
|
||||||
for _, op := range ops {
|
for _, op := range ops {
|
||||||
|
if util.IsExiting {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
switch op.action {
|
switch op.action {
|
||||||
case "upsert":
|
case "upsert":
|
||||||
tree := op.upsertTree
|
tree := op.upsertTree
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
package task
|
package task
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/siyuan-note/siyuan/kernel/util"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
@ -122,6 +123,10 @@ func Loop() {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if util.IsExiting {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
execTask(task)
|
execTask(task)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -292,16 +292,16 @@ func ReindexBlockTree(tree *parse.Tree) {
|
||||||
blockTreesLock.Lock()
|
blockTreesLock.Lock()
|
||||||
defer blockTreesLock.Unlock()
|
defer blockTreesLock.Unlock()
|
||||||
|
|
||||||
var ids []string
|
//var ids []string
|
||||||
for _, b := range blockTrees {
|
//for _, b := range blockTrees {
|
||||||
if b.RootID == tree.ID {
|
// if b.RootID == tree.ID {
|
||||||
ids = append(ids, b.ID)
|
// ids = append(ids, b.ID)
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
ids = gulu.Str.RemoveDuplicatedElem(ids)
|
//ids = gulu.Str.RemoveDuplicatedElem(ids)
|
||||||
for _, id := range ids {
|
//for _, id := range ids {
|
||||||
delete(blockTrees, id)
|
// delete(blockTrees, id)
|
||||||
}
|
//}
|
||||||
|
|
||||||
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus {
|
||||||
if !entering || !n.IsBlock() {
|
if !entering || !n.IsBlock() {
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,9 @@ const (
|
||||||
ExitCodeFatal = 1 // 致命错误
|
ExitCodeFatal = 1 // 致命错误
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// IsExiting 是否正在退出程序。
|
||||||
|
var IsExiting = false
|
||||||
|
|
||||||
func logBootInfo() {
|
func logBootInfo() {
|
||||||
logging.LogInfof("kernel is booting:\n"+
|
logging.LogInfof("kernel is booting:\n"+
|
||||||
" * ver [%s]\n"+
|
" * ver [%s]\n"+
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue