event aggregator uses threadpool to publish events

pull/30/head
kay.one 11 years ago
parent 48c06de098
commit 3d71c129eb

@ -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);
}
}*/
}

@ -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>(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<IHandle<TEvent>>())
{

Loading…
Cancel
Save