public void Ordered_tasks_are_executed_serially() { var taskQueueSettings = new QueuedExecutorSettings{Name = "test"}; var taskQueue = new QueuedExecutor(taskQueueSettings, NullPersister.Instance); var matcher = new NamespaceMatcher(taskQueue.Name, NamespaceMatcher.AnyWildCard); var taskRouter = new TaskRouter(matcher, new IExecutorImplementation[]{taskQueue }); var dispatcher = new TaskDispatcher(2, new IExecutionQueue[] {taskQueue}); var executor = new Executor(taskRouter, dispatcher, new DefaultReleaser()); var tasks = Enumerable.Range(1, 2).Select(x => new LongRunningTask(true) {Name = "Task" + x}).ToArray(); foreach (var task in tasks) { executor.Execute(task); } Assert.That(tasks[0].WaitForStart(1000), Is.True, "First task should start"); Assert.That(tasks[1].WaitForStart(1000), Is.False, "Second task should not start"); }
public IExecutor Build() { if (_built) { throw new InvalidOperationException("Do not call Build more than once."); } _built = true; BuildPersister(); BuildExecutors(); BuildRouter(); _dispatcher = new TaskDispatcher(_maxConcurrency, _executors); _executor = new Executor(_router, _dispatcher, DefaultReleaser.Instance); _container = new DisposableContainer(_executor, _executor, _dispatcher, _router, _executors, _persister, _dataBase); return _container; }
public void SetUp() { _tasks = new List<LongRunningTask>(); var settings = new QueuedExecutorSettings{ Name = "test" }; _queue = new QueuedExecutor(settings, NullPersister.Instance); var settings2 = new QueuedExecutorSettings{ Name = "test" }; _queue2 = new QueuedExecutor(settings2, NullPersister.Instance); _taskDispatcher = new TaskDispatcher(2, new IExecutionQueue[] { _queue, _queue2 }); }