Files
duempelkas/src/Duempelkas.Infrastructure/Services/DatabaseLease.cs
T

13 lines
383 B
C#

namespace Duempelkas.Infrastructure.Services;
internal sealed class DatabaseLease(SemaphoreSlim? gate) : IDisposable
{
public static async Task<DatabaseLease> AcquireAsync(DatabaseLocation? location)
{
if (location != null) await location.Writes.WaitAsync();
return new DatabaseLease(location?.Writes);
}
public void Dispose() => gate?.Release();
}