diff --git a/Wabbajack.FileExtractor.Test/Startup.cs b/Wabbajack.FileExtractor.Test/Startup.cs index 295aa667..0638260a 100644 --- a/Wabbajack.FileExtractor.Test/Startup.cs +++ b/Wabbajack.FileExtractor.Test/Startup.cs @@ -19,7 +19,7 @@ namespace Wabbajack.FileExtractor.Test service.AddSingleton(); service.AddSingleton(new ParallelOptions {MaxDegreeOfParallelism = Environment.ProcessorCount}); service.AddAllSingleton, Resource>(s => - new Resource(2)); + new Resource("File Extractor", 2)); service.AddSingleton(); service.AddSingleton(new JsonSerializerOptions()); } diff --git a/Wabbajack.RateLimiter.Test/RateLimiterTests.cs b/Wabbajack.RateLimiter.Test/RateLimiterTests.cs index 764f068f..1e9595ce 100644 --- a/Wabbajack.RateLimiter.Test/RateLimiterTests.cs +++ b/Wabbajack.RateLimiter.Test/RateLimiterTests.cs @@ -16,7 +16,7 @@ namespace Wabbajack.RateLimiter.Test //[Fact] public async Task BasicTaskTests() { - var rateLimiter = new Resource(2); + var rateLimiter = new Resource("Test Resource", 2); var current = 0; var max = 0; @@ -48,7 +48,7 @@ namespace Wabbajack.RateLimiter.Test //[Fact] public async Task TestBasicThroughput() { - var rateLimiter = new Resource(1, 1024 * 1024); + var rateLimiter = new Resource("Test Resource", 1, 1024 * 1024); using var job = await rateLimiter.Begin( "Transferring", 1024 * 1024 * 5 / 2, CancellationToken.None); @@ -72,7 +72,7 @@ namespace Wabbajack.RateLimiter.Test //[Fact] public async Task TestParallelThroughput() { - var rateLimiter = new Resource(2, 1024 * 1024); + var rateLimiter = new Resource("Test Resource", 2, 1024 * 1024); @@ -100,7 +100,7 @@ namespace Wabbajack.RateLimiter.Test //[Fact] public async Task TestParallelThroughputWithLimitedTasks() { - var rateLimiter = new Resource(1, 1024 * 1024 * 4);; + var rateLimiter = new Resource("Test Resource", 1, 1024 * 1024 * 4);; var sw = Stopwatch.StartNew(); diff --git a/Wabbajack.RateLimiter/Resource.cs b/Wabbajack.RateLimiter/Resource.cs index c1053d7f..1ee7a36a 100644 --- a/Wabbajack.RateLimiter/Resource.cs +++ b/Wabbajack.RateLimiter/Resource.cs @@ -18,12 +18,14 @@ namespace Wabbajack.RateLimiter private long _totalUsed = 0; private readonly int _maxTasks; private readonly long _maxThroughput; - public string Name => typeof(T).Name; + private readonly string _humanName; + public string Name => _humanName; - public Resource(int maxTasks = Int32.MaxValue, long maxThroughput = long.MaxValue) + public Resource(string humanName, int maxTasks = Int32.MaxValue, long maxThroughput = long.MaxValue) { + _humanName = humanName; _maxTasks = maxTasks; _maxThroughput = maxThroughput; diff --git a/Wabbajack.Server.Lib/ServiceExtensions.cs b/Wabbajack.Server.Lib/ServiceExtensions.cs index 2c78b3bd..06b39ab7 100644 --- a/Wabbajack.Server.Lib/ServiceExtensions.cs +++ b/Wabbajack.Server.Lib/ServiceExtensions.cs @@ -15,7 +15,7 @@ namespace Wabbajack.Server.Lib { return services .AddAllSingleton>, IFtpSiteCredentials, FtpSiteCredentialsProvider>() - .AddSingleton>(s => new Resource(8)); + .AddSingleton>(s => new Resource("FTP Uploads", 8)); } } diff --git a/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs b/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs index 04c4d591..388630eb 100644 --- a/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs +++ b/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs @@ -56,11 +56,11 @@ namespace Wabbajack.Services.OSIntegrated : new BinaryPatchCache(KnownFolders.EntryPoint.Combine("patchCache.sqlite"))); service.AddSingleton(new ParallelOptions {MaxDegreeOfParallelism = Environment.ProcessorCount}); - service.AddAllSingleton>(s => new Resource(12)); - service.AddAllSingleton>(s => new Resource(12)); - service.AddAllSingleton>(s => new Resource(12)); + service.AddAllSingleton>(s => new Resource("Downloads", 12)); + service.AddAllSingleton>(s => new Resource("Web Requests", 12)); + service.AddAllSingleton>(s => new Resource("VFS", 12)); service.AddAllSingleton>(s => - new Resource(12)); + new Resource("File Extractor", 12)); service.AddSingleton(); diff --git a/Wabbajack.VFS.Test/Startup.cs b/Wabbajack.VFS.Test/Startup.cs index 6427028d..c971f9e9 100644 --- a/Wabbajack.VFS.Test/Startup.cs +++ b/Wabbajack.VFS.Test/Startup.cs @@ -17,7 +17,7 @@ namespace Wabbajack.VFS.Test { service.AddSingleton(); service.AddAllSingleton, Resource>(s => - new Resource(2)); + new Resource("File Extractor", 2)); // Keep this fixed at 2 so that we can detect deadlocks in the VFS parallelOptions service.AddSingleton(new ParallelOptions {MaxDegreeOfParallelism = 2});