public QueueProcessor(string queueName, int threadCount, TaskExecutionSchedulingPolicy taskExecutionSchedulingPolicy, Priority priority, double schedulingRate, int activateItems) { this.queueName = queueName; this.activateItems = activateItems; if (threadCount > 0) { ThreadPriority threadPriority = this.ConvertThreadPriority(priority); this.dispatcher = DispatcherFactory.CreateDispatcher(threadCount, threadPriority, this.queueName); } else { this.dispatcher = DispatcherFactory.DefaultDispatcher; } if (schedulingRate > 0.0) { TaskExecutionPolicy taskExecutionPolicy = this.ConvertTaskExecutionPolicy(taskExecutionSchedulingPolicy); this.dispatcherQueue = new DispatcherQueue(this.queueName, this.dispatcher, taskExecutionPolicy, schedulingRate); } else { this.dispatcherQueue = new DispatcherQueue(this.queueName, this.dispatcher); } this.upperBound = 0; this.port = new Port <T>(); this.teardownPort = new Port <EmptyValue>(); ReportableObjectDirectory.Add(this.queueName, this); }
private QueueProcessor(string queueName, int threadCount, TaskExecutionPolicy taskExecutionPolicy, ThreadPriority threadPriority, int maximumQueueDepth, double schedulingRate) { this.queueName = queueName; if (threadCount > 0) { this.dispatcher = DispatcherFactory.CreateDispatcher(threadCount, this.queueName); } else { this.dispatcher = DispatcherFactory.DefaultDispatcher; } if (maximumQueueDepth > 0) { this.dispatcherQueue = new DispatcherQueue(this.queueName, this.dispatcher, taskExecutionPolicy, maximumQueueDepth); } else { if (schedulingRate > 0.0) { this.dispatcherQueue = new DispatcherQueue(this.queueName, this.dispatcher, taskExecutionPolicy, schedulingRate); } else { this.dispatcherQueue = new DispatcherQueue(this.queueName, this.dispatcher); } } this.upperBound = maximumQueueDepth; this.port = new Port <T>(); this.teardownPort = new Port <EmptyValue>(); ReportableObjectDirectory.Add(this.queueName, this); }
public virtual void Dispose() { this.disposing = true; ReportableObjectDirectory.Remove(this.queueName); if (this.dispatcher.Name != DispatcherFactory.DefaultDispatcher.Name) { this.dispatcherQueue.Dispose(); this.dispatcher.Dispose(); } else { this.dispatcherQueue.Dispose(); if (DispatcherFactory.DefaultDispatcher != null && DispatcherFactory.DefaultDispatcher.DispatcherQueues.Count == 0) { this.dispatcher = null; DispatcherFactory.DestroyDefaultDispatcher(); } } GC.SuppressFinalize(this); LoggerWrapper.Logger.Debug(string.Format("Teardown of queue {0} completed", new object[] { this.queueName })); }