feat: single setup, mass-pass progress, per-server homes, Desktop shares its library (owner review 5, v1.1.0) (#68)
CI / Build and test (push) Successful in 11m36s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 12s
Release / Build, test and publish (push) Successful in 14m56s
CI / PostgreSQL 16 integration (push) Successful in 10m11s
CI / PostgreSQL 17 integration (push) Successful in 10m15s
CI / Docker image (push) Successful in 45s
Release / Server image (push) Successful in 4m55s

Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #68.
This commit is contained in:
Alby96 authored and Alby96 committed 2026-11-15 18:11:43 +01:00
1 parent 988068ee8e
commit 20d64af4a4
793 files changed
+23882 -2096

No files matched your search

@@ -5,16 +5,71 @@ using Chronos.Testing;
namespace Chronos.Data.Tests.Jobs;
/// <summary>A clock the test moves by hand (BCL <see cref="TimeProvider"/>, no package).</summary>
/// <summary>
/// A clock the test moves by hand (BCL <see cref="TimeProvider"/>, no package), whose timers fire only when
/// <see cref="Advance"/> reaches them, on the test's thread.
/// </summary>
internal sealed class ManualTime : TimeProvider
{
private readonly Lock _gate = new();
private readonly List<Timer> _timers = [];
private long _ticks;
public override long TimestampFrequency => TimeSpan.TicksPerSecond;
public override long GetTimestamp() => Interlocked.Read(ref _ticks);
public void Advance(TimeSpan by) => Interlocked.Add(ref _ticks, by.Ticks);
public override ITimer CreateTimer(TimerCallback callback, object? state, TimeSpan dueTime, TimeSpan period)
{
var timer = new Timer(this, callback, state);
timer.Change(dueTime, period);
return timer;
}
/// <summary>Moves the clock on, then fires each one-shot timer due by then.</summary>
public void Advance(TimeSpan by)
{
List<Timer> due;
lock (_gate)
{
var now = Interlocked.Add(ref _ticks, by.Ticks);
due = [.. _timers.Where(t => t.Due <= now)];
foreach (var timer in due) _timers.Remove(timer);
}
foreach (var timer in due) timer.Fire();
}
private void Schedule(Timer timer, TimeSpan dueTime)
{
lock (_gate)
{
_timers.Remove(timer);
if (dueTime == Timeout.InfiniteTimeSpan) return;
timer.Due = Interlocked.Read(ref _ticks) + dueTime.Ticks;
_timers.Add(timer);
}
}
private sealed class Timer(ManualTime clock, TimerCallback callback, object? state) : ITimer
{
public long Due { get; set; }
public bool Change(TimeSpan dueTime, TimeSpan period)
{
clock.Schedule(this, dueTime);
return true;
}
public void Fire() => callback(state);
public void Dispose() => clock.Schedule(this, Timeout.InfiniteTimeSpan);
public ValueTask DisposeAsync()
{
Dispose();
return ValueTask.CompletedTask;
}
}
}
[Category("jobs")]