mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-21 14:03:29 -07:00
more granular Concurrency control.
indexer calls are done fully paralleled. events are dispatched on max of 2 threads.
This commit is contained in:
parent
763df726f0
commit
9181b1bb91
12 changed files with 377 additions and 37 deletions
|
@ -112,21 +112,33 @@ namespace NzbDrone.Core.IndexerSearch
|
|||
var indexers = _indexerService.GetAvailableIndexers().ToList();
|
||||
var reports = new List<ReportInfo>();
|
||||
|
||||
Parallel.ForEach(indexers, indexer =>
|
||||
|
||||
var taskList = new List<Task>();
|
||||
var taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.None);
|
||||
|
||||
foreach (var indexer in indexers)
|
||||
{
|
||||
try
|
||||
var indexerLocal = indexer;
|
||||
|
||||
taskList.Add(taskFactory.StartNew(() =>
|
||||
{
|
||||
var indexerReports = searchAction(indexer);
|
||||
lock (indexer)
|
||||
try
|
||||
{
|
||||
reports.AddRange(indexerReports);
|
||||
var indexerReports = searchAction(indexerLocal);
|
||||
|
||||
lock (reports)
|
||||
{
|
||||
reports.AddRange(indexerReports);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorException(String.Format("An error has occurred while searching for {0} from: {1}", definitionBase, indexer.Name), e);
|
||||
}
|
||||
});
|
||||
catch (Exception e)
|
||||
{
|
||||
_logger.ErrorException("Error while searching for " + definitionBase, e);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
Task.WaitAll(taskList.ToArray());
|
||||
|
||||
_logger.Debug("Total of {0} reports were found for {1} in {2} indexers", reports.Count, definitionBase, indexers.Count);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue