This commit is contained in:
Daniel 2025-04-10 11:59:56 +08:00
parent 9729b72a9e
commit 669dfb7d58
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 11 additions and 2 deletions

View file

@ -23,6 +23,7 @@ import (
"path"
"runtime/debug"
"sync"
"sync/atomic"
"time"
"github.com/88250/lute/parse"
@ -63,15 +64,21 @@ func ClearQueue() {
operationQueue = nil
}
var flushingTx = atomic.Bool{}
func FlushQueue() {
ops := getOperations()
total := len(ops)
if 1 > total {
if 1 > total && !flushingTx.Load() {
return
}
txLock.Lock()
defer txLock.Unlock()
flushingTx.Store(true)
defer func() {
flushingTx.Store(false)
txLock.Unlock()
}()
start := time.Now()