wabbajack/Wabbajack.RateLimiter/Job.cs
Timothy Baldridge fc2530d33f Fix tests
2021-10-23 16:27:59 -06:00

36 lines
890 B
C#

using System;
using System.Threading;
using System.Threading.Tasks;
namespace Wabbajack.RateLimiter;
public class Job<T> : IJob, IDisposable
{
public ulong ID { get; internal init; }
public string Description { get; internal init; }
public bool Started { get; internal set; }
public IResource<T> Resource { get; init; }
private bool _isFinished = false;
public void Dispose()
{
if (_isFinished) return;
_isFinished = true;
Resource.Finish(this);
}
public long Current { get; internal set; }
public long? Size { get; set; }
public async ValueTask Report(int processedSize, CancellationToken token)
{
await Resource.Report(this, processedSize, token);
Current += processedSize;
}
public void ReportNoWait(int processedSize)
{
Resource.ReportNoWait(this, processedSize);
}
}