mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-05 15:11:48 +01:00
🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113
This commit is contained in:
parent
e782e034cc
commit
07abcd0121
9 changed files with 15 additions and 18 deletions
|
|
@ -175,8 +175,8 @@ func checkBlockExist(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Data = id
|
||||
ret.Code = 0
|
||||
ret.Data = false
|
||||
return
|
||||
}
|
||||
ret.Data = nil != b
|
||||
|
|
@ -384,7 +384,7 @@ func getBlockInfo(c *gin.Context) {
|
|||
}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Data = id
|
||||
ret.Msg = model.Conf.Language(56)
|
||||
return
|
||||
}
|
||||
if nil == block {
|
||||
|
|
@ -415,7 +415,7 @@ func getBlockInfo(c *gin.Context) {
|
|||
}
|
||||
if errors.Is(err, model.ErrIndexing) {
|
||||
ret.Code = 3
|
||||
ret.Data = id
|
||||
ret.Data = model.Conf.Language(56)
|
||||
return
|
||||
}
|
||||
rootTitle := root.IAL["title"]
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@ func getBlock(id string) (ret *Block, err error) {
|
|||
|
||||
tree, err := loadTreeByBlockID(id)
|
||||
if nil != err {
|
||||
if indexing {
|
||||
if isIndexing() {
|
||||
err = ErrIndexing
|
||||
}
|
||||
return
|
||||
|
|
|
|||
|
|
@ -54,10 +54,12 @@ func (box *Box) Index() {
|
|||
|
||||
var indexing = false
|
||||
|
||||
func waitForIndexing() {
|
||||
for indexing {
|
||||
func isIndexing() (ret bool) {
|
||||
for i := 0; indexing || i > 7; i++ {
|
||||
time.Sleep(time.Millisecond * 100)
|
||||
ret = true
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func index(boxID string) {
|
||||
|
|
|
|||
|
|
@ -144,8 +144,6 @@ func StatusLoop() {
|
|||
}
|
||||
}
|
||||
|
||||
var taskWaitGroup = sync.WaitGroup{}
|
||||
|
||||
func Loop() {
|
||||
for {
|
||||
time.Sleep(10 * time.Millisecond)
|
||||
|
|
@ -163,9 +161,7 @@ func Loop() {
|
|||
break
|
||||
}
|
||||
|
||||
taskWaitGroup.Add(1)
|
||||
go execTask(task)
|
||||
taskWaitGroup.Wait()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -202,5 +198,4 @@ func execTask(task *Task) {
|
|||
}
|
||||
|
||||
task.Handler.Call(args)
|
||||
taskWaitGroup.Done()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue