Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Clean code https://github.com/siyuan-note/siyuan/pull/16880

Daniel185a43a95414
diff --git a/kernel/sql/queue.go b/kernel/sql/queue.go
index 49339f41b9..7883eddf64 100644
--- a/kernel/sql/queue.go
+++ b/kernel/sql/queue.go
@@ -65,17 +65,15 @@ func WaitFlushTx() {
dbQueueLock.Lock()
defer dbQueueLock.Unlock()
- var printLog bool
- var lastPrintLog bool
+ var printLog, lastPrintLog bool
var i int
for len(operationQueue) > 0 || flushingTx.Load() {
- // 使用条件变量等待,避免轮询浪费 CPU
if i == 0 {
- // 第一次等待时使用较短的超时,与原逻辑保持一致
+ // 第一次等待时使用较短的超时
dbQueueCond.Wait()
} else {
- // 后续等待添加超时检测,用于打印警告日志
+ // 后续等待添加超时检测,用于打印警告日志
timer := time.AfterFunc(50*time.Millisecond, func() {
dbQueueCond.Broadcast()
})
@@ -95,20 +93,6 @@ func WaitFlushTx() {
}
}
-func isWritingDatabase(d time.Duration) bool {
- // 等待指定时间后再检查状态
- if d > 0 {
- time.Sleep(d)
- }
-
- dbQueueLock.Lock()
- defer dbQueueLock.Unlock()
- if 0 < len(operationQueue) || flushingTx.Load() {
- return true
- }
- return false
-}
-
func ClearQueue() {
dbQueueLock.Lock()
defer dbQueueLock.Unlock()