🎨 Improve .sy data file writing transaction https://github.com/siyuan-note/siyuan/issues/11834
This commit is contained in:
parent
63d5a2114f
commit
abc3eb76c5
1 changed files with 9 additions and 4 deletions
|
@ -72,13 +72,14 @@ func WaitForWritingFiles() {
|
|||
}
|
||||
|
||||
var (
|
||||
txQueue = make(chan *Transaction, 7)
|
||||
flushLock = sync.Mutex{}
|
||||
txQueue = make(chan *Transaction, 7)
|
||||
flushLock = sync.Mutex{}
|
||||
isFlushing = false
|
||||
)
|
||||
|
||||
func isWritingFiles() bool {
|
||||
time.Sleep(time.Duration(50) * time.Millisecond)
|
||||
return 0 < len(txQueue)
|
||||
return 0 < len(txQueue) || isFlushing
|
||||
}
|
||||
|
||||
func init() {
|
||||
|
@ -95,7 +96,11 @@ func init() {
|
|||
func flushTx(tx *Transaction) {
|
||||
defer logging.Recover()
|
||||
flushLock.Lock()
|
||||
defer flushLock.Unlock()
|
||||
isFlushing = true
|
||||
defer func() {
|
||||
isFlushing = false
|
||||
flushLock.Unlock()
|
||||
}()
|
||||
|
||||
start := time.Now()
|
||||
if txErr := performTx(tx); nil != txErr {
|
||||
|
|
Loading…
Add table
Reference in a new issue