wabbajack/Wabbajack.RateLimiter/Job.cs

32 lines
790 B
C#
Raw Normal View History

2021-09-27 12:42:46 +00:00
using System;
using System.Threading;
using System.Threading.Tasks;
2021-10-23 16:51:17 +00:00
namespace Wabbajack.RateLimiter;
public class Job<T> : IJob, IDisposable
2021-09-27 12:42:46 +00:00
{
2021-10-23 16:51:17 +00:00
public ulong ID { get; internal init; }
public string Description { get; internal init; }
public bool Started { get; internal set; }
public IResource<T> Resource { get; init; }
public void Dispose()
{
Resource.Finish(this);
}
public long Current { get; internal set; }
public long? Size { get; set; }
public async ValueTask Report(int processedSize, CancellationToken token)
2021-09-27 12:42:46 +00:00
{
2021-10-23 16:51:17 +00:00
await Resource.Report(this, processedSize, token);
Current += processedSize;
}
2021-09-27 12:42:46 +00:00
2021-10-23 16:51:17 +00:00
public void ReportNoWait(int processedSize)
{
Resource.ReportNoWait(this, processedSize);
2021-09-27 12:42:46 +00:00
}
}