Skip to content

Commit

Permalink
Fix ThreadPooledJobStore, which also fixes the queue
Browse files Browse the repository at this point in the history
  • Loading branch information
da3dsoul committed Jan 8, 2024
1 parent 0ec403f commit a95d740
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Shoko.Server/Scheduling/ThreadPooledJobStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,19 @@ protected override async Task<IReadOnlyCollection<IOperableTrigger>> AcquireNext

if (ObjectUtils.IsAttributePresent(jobType, typeof(DisallowConcurrentExecutionAttribute)))
{
if (acquiredJobKeysForNoConcurrentExec.ContainsKey(jobType)) continue;
acquiredJobKeysForNoConcurrentExec[jobType] += 1;
if (acquiredJobKeysForNoConcurrentExec.TryGetValue(jobType, out var number) && number >= 1) continue;
acquiredJobKeysForNoConcurrentExec[jobType] = number + 1;
}
else if (jobType.GetCustomAttributes().FirstOrDefault(a => a is LimitConcurrencyAttribute) is LimitConcurrencyAttribute attribute)
{
if (!_typeConcurrencyCache.TryGetValue(jobType, out var maxConcurrentJobs)) maxConcurrentJobs = attribute.MaxConcurrentJobs;
if (acquiredJobKeysForNoConcurrentExec.TryGetValue(jobType, out var number) && number >= maxConcurrentJobs) continue;
acquiredJobKeysForNoConcurrentExec[jobType] += 1;
acquiredJobKeysForNoConcurrentExec[jobType] = number + 1;
}
else if (_typeConcurrencyCache.TryGetValue(jobType, out var maxJobs) && maxJobs > 0)
{
if (acquiredJobKeysForNoConcurrentExec.TryGetValue(jobType, out var number) && number >= maxJobs) continue;
acquiredJobKeysForNoConcurrentExec[jobType] += 1;
acquiredJobKeysForNoConcurrentExec[jobType] = number + 1;
}

var nextFireTimeUtc = nextTrigger.GetNextFireTimeUtc();
Expand Down

0 comments on commit a95d740

Please sign in to comment.