protected void Dispose(bool disposing) { if (!mIsDisposed) { if (disposing) { StopAync().Wait(); mTaskPoller.Dispose(); mTaskBuffer.Dispose(); if (mTaskResultQueue is IDisposable) { (( IDisposable )mTaskResultQueue).Dispose(); } mTaskPoller = null; mTaskBuffer = null; mTaskResultQueue = null; mTaskQueueConsumer = null; mExecutorRegistry = null; } mIsDisposed = true; } }
public StandardTaskEngine(TaskEngineOptions engineOptions, TaskQueueOptions producerAndResultOptions, TaskQueueConsumerOptions consumerOptions, ITaskExecutorRegistry executorRegistry, IExecutionPerformanceMonitorWriter executionPerfMonWriter, ITimestampProvider timestampProvider) { if (engineOptions == null) { throw new ArgumentNullException(nameof(engineOptions)); } if (consumerOptions == null) { throw new ArgumentNullException(nameof(consumerOptions)); } if (producerAndResultOptions == null) { throw new ArgumentNullException(nameof(producerAndResultOptions)); } mExecutorRegistry = executorRegistry ?? throw new ArgumentNullException(nameof(executorRegistry)); mExecutionPerfMonWriter = executionPerfMonWriter ?? throw new ArgumentNullException(nameof(executionPerfMonWriter)); mExecutionPerfMon = new StandardExecutionPerformanceMonitor(); mTaskQueueConsumer = new PostgreSqlTaskQueueConsumer(consumerOptions, timestampProvider); mTaskQueueProducer = new PostgreSqlTaskQueueProducer(producerAndResultOptions, timestampProvider); mTaskResultQueue = new PostgreSqlTaskResultQueue(producerAndResultOptions); mTaskBuffer = new StandardTaskBuffer(engineOptions.WorkerCount); mTaskPoller = new StandardTaskPoller(engineOptions.TaskProcessingOptions, mTaskQueueConsumer, mTaskBuffer); mOptions = engineOptions; }