This commit is contained in:
xljiulang 2021-06-16 20:29:45 +08:00
parent fcb7d51731
commit 52f73f8790

View File

@ -8,7 +8,13 @@ namespace FastGithub.Scanner.Middlewares
[Service(ServiceLifetime.Singleton)] [Service(ServiceLifetime.Singleton)]
sealed class ConcurrentMiddleware : IMiddleware<GithubContext> sealed class ConcurrentMiddleware : IMiddleware<GithubContext>
{ {
private readonly SemaphoreSlim semaphoreSlim = new(Environment.ProcessorCount * 4); private readonly SemaphoreSlim semaphoreSlim;
public ConcurrentMiddleware()
{
var initialCount = Environment.ProcessorCount;
this.semaphoreSlim = new SemaphoreSlim(initialCount, initialCount * 4);
}
public async Task InvokeAsync(GithubContext context, Func<Task> next) public async Task InvokeAsync(GithubContext context, Func<Task> next)
{ {