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
|
@ -38,15 +38,28 @@ namespace NzbDrone.Core.Indexers
|
|||
|
||||
_logger.Debug("Available indexers {0}", indexers.Count);
|
||||
|
||||
Parallel.ForEach(indexers, new ParallelOptions { MaxDegreeOfParallelism = 10 }, indexer =>
|
||||
{
|
||||
var indexerFeed = _feedFetcher.FetchRss(indexer);
|
||||
|
||||
lock (result)
|
||||
{
|
||||
result.AddRange(indexerFeed);
|
||||
}
|
||||
});
|
||||
var taskList = new List<Task>();
|
||||
var taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.None);
|
||||
|
||||
foreach (var indexer in indexers)
|
||||
{
|
||||
var indexerLocal = indexer;
|
||||
|
||||
var task = taskFactory.StartNew(() =>
|
||||
{
|
||||
var indexerFeed = _feedFetcher.FetchRss(indexerLocal);
|
||||
|
||||
lock (result)
|
||||
{
|
||||
result.AddRange(indexerFeed);
|
||||
}
|
||||
});
|
||||
|
||||
taskList.Add(task);
|
||||
}
|
||||
|
||||
Task.WaitAll(taskList.ToArray());
|
||||
|
||||
_logger.Debug("Found {0} reports", result.Count);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue