From 185a43a954149b935c6a95eb6a23432f8c0c19fa Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Sat, 7 Feb 2026 10:45:37 +0800 Subject: [PATCH] :art: Clean code https://github.com/siyuan-note/siyuan/pull/16880 Signed-off-by: Daniel <845765@qq.com> --- kernel/sql/queue.go | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/kernel/sql/queue.go b/kernel/sql/queue.go index 49339f41b..7883eddf6 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()