Skip to content

Commit

Permalink
Simplified DiskWriterQueue with blocking concurrency
Browse files Browse the repository at this point in the history
  • Loading branch information
ltetak committed Jan 25, 2024
1 parent 33f85d5 commit 13ab9ef
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion LiteDB/Engine/Disk/DiskWriterQueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ private void ExecuteQueue()
}
else
{
_stream.FlushToDisk();
TryFlushStream();

lock (_queueSync)
{
if (_queue.Count > 0) continue;
Expand All @@ -85,6 +86,18 @@ private void ExecuteQueue()
}
}

private void TryFlushStream()
{
try
{
_stream.FlushToDisk();
}
catch (IOException)
{
// Disk is probably full. This may be unrecoverable problem but until we have enough space in the buffer we may be ok.
}
}

private void WritePageToStream(PageBuffer page)
{
if (page == null) return;
Expand Down

0 comments on commit 13ab9ef

Please sign in to comment.