1
0
mirror of https://github.com/Radarr/Radarr.git synced 2026-04-22 22:15:17 -04:00

more granular Concurrency control.

indexer calls are done fully paralleled.
events are dispatched on max of 2 threads.
This commit is contained in:
Keivan Beigi
2013-05-29 18:35:26 -07:00
parent 763df726f0
commit 9181b1bb91
12 changed files with 377 additions and 37 deletions
@@ -9,6 +9,7 @@ using NzbDrone.Core.Indexers;
using NzbDrone.Core.Indexers.Newznab;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Test.Common;
namespace NzbDrone.Core.Test.IndexerTests
{
@@ -45,26 +46,20 @@ namespace NzbDrone.Core.Test.IndexerTests
[Explicit]
public void should_call_fetch_on_all_indexers_at_the_same_time()
{
var callsToFetch = new List<DateTime>();
var counter = new ConcurrencyCounter(_indexers.Count);
Mocker.GetMock<IFetchFeedFromIndexers>().Setup(c => c.FetchRss(It.IsAny<IIndexer>()))
.Returns(new List<ReportInfo>())
.Callback((() =>
{
Thread.Sleep(2000);
Console.WriteLine(DateTime.Now);
callsToFetch.Add(DateTime.Now);
}));
.Callback((() => counter.SimulateWork(500)));
Mocker.GetMock<IIndexerService>().Setup(c => c.GetAvailableIndexers()).Returns(_indexers);
Subject.Fetch();
counter.WaitForAllItems();
var first = callsToFetch.Min();
var last = callsToFetch.Max();
(last - first).Should().BeLessThan(TimeSpan.FromSeconds(1));
counter.MaxThreads.Should().Be(_indexers.Count);
}
}
}