mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 改进内核任务调度机制提升稳定性 https://github.com/siyuan-note/siyuan/issues/7113
This commit is contained in:
parent
981e598149
commit
b5fc879628
4 changed files with 32 additions and 4 deletions
|
|
@ -37,12 +37,13 @@ var (
|
|||
|
||||
type dbQueueOperation struct {
|
||||
inQueueTime time.Time
|
||||
action string // upsert/delete/delete_id/rename/delete_box/delete_box_refs/insert_refs
|
||||
action string // upsert/delete/delete_id/rename/delete_box/delete_box_refs/insert_refs/index
|
||||
|
||||
indexPath string // index
|
||||
upsertTree *parse.Tree // upsert/insert_refs
|
||||
removeTreeBox, removeTreePath string // delete
|
||||
removeTreeIDBox, removeTreeID string // delete_id
|
||||
box string // delete_box/delete_box_refs
|
||||
box string // delete_box/delete_box_refs/index
|
||||
renameTree *parse.Tree // rename
|
||||
renameTreeOldHPath string // rename
|
||||
}
|
||||
|
|
@ -110,6 +111,8 @@ func FlushQueue() {
|
|||
}
|
||||
|
||||
switch op.action {
|
||||
case "index":
|
||||
err = indexTree(tx, op.box, op.indexPath, context)
|
||||
case "upsert":
|
||||
err = upsertTree(tx, op.upsertTree, context)
|
||||
case "delete":
|
||||
|
|
@ -231,6 +234,20 @@ func DeleteBoxQueue(boxID string) {
|
|||
operationQueue = append(operationQueue, newOp)
|
||||
}
|
||||
|
||||
func IndexTreeQueue(box, p string) {
|
||||
dbQueueLock.Lock()
|
||||
defer dbQueueLock.Unlock()
|
||||
|
||||
newOp := &dbQueueOperation{indexPath: p, box: box, inQueueTime: time.Now(), action: "index"}
|
||||
for i, op := range operationQueue {
|
||||
if "index" == op.action && op.indexPath == p && op.box == box { // 相同树则覆盖
|
||||
operationQueue[i] = newOp
|
||||
return
|
||||
}
|
||||
}
|
||||
operationQueue = append(operationQueue, newOp)
|
||||
}
|
||||
|
||||
func UpsertTreeQueue(tree *parse.Tree) {
|
||||
dbQueueLock.Lock()
|
||||
defer dbQueueLock.Unlock()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue