1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 20:42:37 +01:00

event aggregator uses threadpool to publish events

This commit is contained in:
kay.one 2013-09-16 21:52:33 -07:00
parent 6583b10975
commit 2a0090e5ce
2 changed files with 21 additions and 5 deletions

View File

@ -88,7 +88,7 @@ public void broken_handler_should_not_effect_others_handler()
}
[Test]
/* [Test]
public void should_queue_multiple_async_events()
{
var eventA = new EventA();
@ -130,7 +130,7 @@ public void should_queue_multiple_async_events()
counter.WaitForAllItems();
counter.MaxThreads.Should().Be(3);
}
}*/
}

View File

@ -16,11 +16,9 @@ public class EventAggregator : IEventAggregator
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 @@ public void PublishEvent<TEvent>(TEvent @event) where TEvent : class ,IEvent
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>>())
{