Commit resync writes in one transaction
Each insert, delete and rescore update was its own commit to disk, so a resync of about a thousand QSOs froze the window thread. LogStore has a new Batch() scope that commits its writes together. ContestSession uses it in AddRangeFromNetwork, ClearFromNetwork and Rescore. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -128,9 +128,12 @@ public sealed class ContestSession
|
||||
&& q.TimestampUtc >= fromUtc
|
||||
&& q.TimestampUtc < fromUtc + length)
|
||||
.ToList();
|
||||
foreach (Qso qso in gone)
|
||||
using (store.Batch())
|
||||
{
|
||||
store.Delete(qso.Id);
|
||||
foreach (Qso qso in gone)
|
||||
{
|
||||
store.Delete(qso.Id);
|
||||
}
|
||||
}
|
||||
if (gone.Count > 0)
|
||||
{
|
||||
@@ -152,10 +155,13 @@ public sealed class ContestSession
|
||||
{
|
||||
Log.Rescore();
|
||||
int written = 0;
|
||||
foreach (Qso qso in Log.Qsos.Where(q => q.TimestampUtc >= fromUtc))
|
||||
using (store.Batch())
|
||||
{
|
||||
store.Update(qso);
|
||||
written++;
|
||||
foreach (Qso qso in Log.Qsos.Where(q => q.TimestampUtc >= fromUtc))
|
||||
{
|
||||
store.Update(qso);
|
||||
written++;
|
||||
}
|
||||
}
|
||||
Changed?.Invoke(this, EventArgs.Empty);
|
||||
return written;
|
||||
@@ -216,11 +222,14 @@ public sealed class ContestSession
|
||||
{
|
||||
HashSet<string> held = [.. Log.Qsos.Select(q => q.Id)];
|
||||
List<Qso> stored = [];
|
||||
foreach (Qso qso in arriving)
|
||||
using (store.Batch())
|
||||
{
|
||||
if (held.Add(qso.Id))
|
||||
foreach (Qso qso in arriving)
|
||||
{
|
||||
stored.Add(store.Add(FromNetwork(qso)));
|
||||
if (held.Add(qso.Id))
|
||||
{
|
||||
stored.Add(store.Add(FromNetwork(qso)));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stored.Count == 0)
|
||||
|
||||
Reference in New Issue
Block a user