using System; using System.Collections.Generic; namespace Flyinsono.Client.Test.Utilities.Executors { /// /// This executor will run workers one by one. /// /// public class SequenceExecutor:ExecutorBase where T: class { private readonly Queue> _workers = new Queue>(); public SequenceExecutor(string name) : base(name) { } public SequenceExecutor(string name, TimeSpan executeDelayTime) : base(name, executeDelayTime) { } /// /// Gets current worker count in queue. /// /// protected override int GetWorkerCount() { return _workers.Count; } /// /// Add one worker into the queue. /// /// protected override void AddWorker(ExecuteWorker worker) { _workers.Enqueue(worker); } /// /// Take one worker from the queue. /// /// protected override ExecuteWorker TakeWorker() { return _workers.Dequeue(); } /// /// Gets all workers. /// /// protected override IEnumerable> GetWorkers() { return _workers.ToArray(); } /// /// Clear all workers which not stated. /// protected override void CancelWorkers() { _workers.Clear(); } /// /// Get the rest not working workers /// /// public IEnumerable> GetRestWorkers() { return GetWorkers(); } } }