From 2a0090e5ce192fd3c3632680b11dda4a7acc6105 Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Mon, 16 Sep 2013 21:52:33 -0700 Subject: [PATCH] event aggregator uses threadpool to publish events --- .../Events/EventAggregatorFixture.cs | 4 ++-- .../Messaging/Events/EventAggregator.cs | 22 ++++++++++++++++--- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/NzbDrone.Core.Test/Messaging/Events/EventAggregatorFixture.cs b/NzbDrone.Core.Test/Messaging/Events/EventAggregatorFixture.cs index f1fc6bee1..e5bdd313a 100644 --- a/NzbDrone.Core.Test/Messaging/Events/EventAggregatorFixture.cs +++ b/NzbDrone.Core.Test/Messaging/Events/EventAggregatorFixture.cs @@ -88,7 +88,7 @@ namespace NzbDrone.Core.Test.Messaging.Events } - [Test] + /* [Test] public void should_queue_multiple_async_events() { var eventA = new EventA(); @@ -130,7 +130,7 @@ namespace NzbDrone.Core.Test.Messaging.Events counter.WaitForAllItems(); counter.MaxThreads.Should().Be(3); - } + }*/ } diff --git a/NzbDrone.Core/Messaging/Events/EventAggregator.cs b/NzbDrone.Core/Messaging/Events/EventAggregator.cs index 7dbe1a331..891d1c8b8 100644 --- a/NzbDrone.Core/Messaging/Events/EventAggregator.cs +++ b/NzbDrone.Core/Messaging/Events/EventAggregator.cs @@ -16,11 +16,9 @@ namespace NzbDrone.Core.Messaging.Events public EventAggregator(Logger logger, IServiceFactory serviceFactory) { - var scheduler = new LimitedConcurrencyLevelTaskScheduler(3); - _logger = logger; _serviceFactory = serviceFactory; - _taskFactory = new TaskFactory(scheduler); + _taskFactory = new TaskFactory(); } public void PublishEvent(TEvent @event) where TEvent : class ,IEvent @@ -29,8 +27,26 @@ namespace NzbDrone.Core.Messaging.Events var eventName = GetEventName(@event.GetType()); +/* + int workerThreads; + int completionPortThreads; + ThreadPool.GetAvailableThreads(out workerThreads, out completionPortThreads); + + int maxCompletionPortThreads; + int maxWorkerThreads; + ThreadPool.GetMaxThreads(out maxWorkerThreads, out maxCompletionPortThreads); + + + int minCompletionPortThreads; + int minWorkerThreads; + ThreadPool.GetMinThreads(out minWorkerThreads, out minCompletionPortThreads); + + _logger.Warn("Thread pool state WT:{0} PT:{1} MAXWT:{2} MAXPT:{3} MINWT:{4} MINPT:{5}", workerThreads, completionPortThreads, maxWorkerThreads, maxCompletionPortThreads, minWorkerThreads, minCompletionPortThreads); +*/ + _logger.Trace("Publishing {0}", eventName); + //call synchronous handlers first. foreach (var handler in _serviceFactory.BuildAll>()) {