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

This commit is contained in:
Liang Ding 2023-01-24 21:50:10 +08:00
parent e8fe3a77b3
commit c5f4d3c780
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
19 changed files with 86 additions and 28 deletions

View file

@ -20,6 +20,7 @@ import (
"bytes"
"errors"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"io/ioutil"
"os"
"path"
@ -39,7 +40,6 @@ import (
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)

View file

@ -105,7 +105,7 @@ func InitConf() {
if userLang, err := locale.Detect(); nil == err {
var supportLangs []language.Tag
for lang := range langs {
for lang := range util.Langs {
if tag, err := language.Parse(lang); nil == err {
supportLangs = append(supportLangs, tag)
} else {
@ -125,6 +125,7 @@ func InitConf() {
Conf.Lang = util.Lang
}
}
util.Lang = Conf.Lang
}
Conf.Langs = loadLangs()
@ -140,6 +141,7 @@ func InitConf() {
}
if !langOK {
Conf.Lang = "en_US"
util.Lang = Conf.Lang
}
Conf.Appearance.Lang = Conf.Lang
if nil == Conf.UILayout {
@ -321,9 +323,6 @@ func InitConf() {
util.SetNetworkProxy(Conf.System.NetworkProxy.String())
}
var langs = map[string]map[int]string{}
var timeLangs = map[string]map[string]interface{}{}
func initLang() {
p := filepath.Join(util.WorkingDir, "appearance", "langs")
dir, err := os.Open(p)
@ -363,14 +362,15 @@ func initLang() {
}
kernelMap[-1] = label
name := langName[:strings.LastIndex(langName, ".")]
langs[name] = kernelMap
util.Langs[name] = kernelMap
timeLangs[name] = langMap["_time"].(map[string]interface{})
util.TimeLangs[name] = langMap["_time"].(map[string]interface{})
util.TaskActionLangs[name] = langMap["_taskAction"].(map[string]interface{})
}
}
func loadLangs() (ret []*conf.Lang) {
for name, langMap := range langs {
for name, langMap := range util.Langs {
lang := &conf.Lang{Label: langMap[-1], Name: name}
ret = append(ret, lang)
}
@ -567,11 +567,11 @@ func (conf *AppConf) GetClosedBoxes() (ret []*Box) {
}
func (conf *AppConf) Language(num int) (ret string) {
ret = langs[conf.Lang][num]
ret = util.Langs[conf.Lang][num]
if "" != ret {
return
}
ret = langs["en_US"][num]
ret = util.Langs["en_US"][num]
return
}

View file

@ -19,6 +19,7 @@ package model
import (
"errors"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"math"
"os"
"path"
@ -43,7 +44,6 @@ import (
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/search"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -97,7 +97,7 @@ func (box *Box) docFromFileInfo(fileInfo *FileInfo, ial map[string]string) (ret
}
func HumanizeTime(then time.Time) string {
labels := timeLangs[Conf.Lang]
labels := util.TimeLangs[Conf.Lang]
defaultMagnitudes := []humanize.RelTimeMagnitude{
{time.Second, labels["now"].(string), time.Second},

View file

@ -19,6 +19,7 @@ package model
import (
"encoding/json"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"io/fs"
"math"
"os"
@ -38,7 +39,6 @@ import (
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/search"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)

View file

@ -18,6 +18,7 @@ package model
import (
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"strings"
"time"
@ -29,7 +30,6 @@ import (
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)

View file

@ -1,6 +1,7 @@
package model
import (
"github.com/siyuan-note/siyuan/kernel/task"
"io"
"os"
"path/filepath"
@ -15,7 +16,6 @@ import (
"github.com/panjf2000/ants/v2"
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/util"
)

View file

@ -23,6 +23,7 @@ import (
"encoding/base64"
"errors"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"math"
"net/http"
"os"
@ -49,7 +50,6 @@ import (
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
"github.com/studio-b12/gowebdav"

View file

@ -20,6 +20,7 @@ import (
"bytes"
"errors"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"path"
"regexp"
"sort"
@ -38,7 +39,6 @@ import (
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/search"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
"github.com/xrash/smetrics"

View file

@ -32,7 +32,6 @@ import (
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/conf"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)
@ -92,12 +91,8 @@ func BootSyncData() {
}
func SyncData(boot, exit, byHand bool) {
if !checkSync(boot, exit, byHand) {
return
}
util.BroadcastByType("main", "syncing", 0, Conf.Language(81), nil)
task.PrependTask(task.CloudSync, syncData, boot, exit, byHand)
syncData(boot, exit, byHand)
}
func syncData(boot, exit, byHand bool) {

View file

@ -20,6 +20,7 @@ import (
"bytes"
"errors"
"fmt"
"github.com/siyuan-note/siyuan/kernel/task"
"os"
"path"
"path/filepath"
@ -38,7 +39,6 @@ import (
"github.com/siyuan-note/logging"
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/sql"
"github.com/siyuan-note/siyuan/kernel/task"
"github.com/siyuan-note/siyuan/kernel/treenode"
"github.com/siyuan-note/siyuan/kernel/util"
)