/// <summary> /// Starts this instance and initializes all the timers and queues. /// </summary> /// <returns></returns> public bool Start() { if (serviceStatus == ServiceStatus.Stopped) { CheckAbnormallyTerminatedJobs(); CalculateJobsNextExecutionTimes(); foreach (QueueDefinition queueDefinition in SettingsProvider.Queues) { IExecutionQueue queue = Utils.CreateInstanceWithRequiredInterface <IExecutionQueue>(queueDefinition.Type, typeof(IExecutionQueue).AssemblyQualifiedName); if (queue != null) { jobQueues.Add(queueDefinition.Id, queue); jobQueues[queueDefinition.Id].Id = queueDefinition.Id; jobQueues[queueDefinition.Id].ThreadCount = queueDefinition.ThreadCount; jobQueues[queueDefinition.Id].JobFinishedExecuting += new EventHandler <JobFinishedExecutingEventArgs>(Queue_JobFinishedExecuting); } } //To change the accuracy of scheduled jobs, this interval can be changed. pollTimer.Interval = SettingsProvider.PollFrequency.TotalMilliseconds; pollTimer.Start(); serviceStatus = ServiceStatus.Running; return(true); } else if (serviceStatus == ServiceStatus.Paused) { return(Resume()); } return(false); }
public QueuePresenter(IQueueView view, IExecutionQueue queue, IQueuedItemFactory factory) { _queue = queue; _view = view; _items.OnMissing = factory.Build; }
public QueuedTestItem(Test test, IExecutionQueue queue, IScreenConductor shell) : this() { linkText.Content = test.LocatorPath(); link.Click += (x, y) => shell.OpenScreen(test); stop.Click += (x, y) => queue.Cancel(test); }
public TestService(IExecutionQueue queue, ITestConverter converter, IEventAggregator events, FixtureLibrary library) { _queue = queue; _converter = converter; _events = events; _library = library; }
public StatusPresenter(IStatusView view, IScreenConductor shell, GrammarErrorsSubject errors, IExecutionQueue queue) { _view = view; _conductor = shell; _errors = errors; _queue = queue; }
/// <summary> /// Starts this instance and initializes all the timers and queues. /// </summary> /// <returns></returns> public bool Start() { if (serviceStatus == ServiceStatus.Stopped) { CheckAbnormallyTerminatedJobs(); foreach (QueueDefinition queueDefinition in SettingsProvider.Queues) { IExecutionQueue queue = (IExecutionQueue)Utils.CreateInstanceWithRequiredInterface(queueDefinition.Type, typeof(IExecutionQueue).Name); if (queue != null) { jobQueues.Add(queueDefinition.Id, queue); jobQueues[queueDefinition.Id].Id = queueDefinition.Id; jobQueues[queueDefinition.Id].ThreadCount = queueDefinition.ThreadCount; jobQueues[queueDefinition.Id].JobFinishedExecuting += new EventHandler <JobFinishedExecutingEventArgs>(Queue_JobFinishedExecuting); } } jobQueueTimer.Interval = SettingsProvider.PollFrequency.TotalMilliseconds; jobQueueTimer.Start(); //To change the accuracy of scheduled jobs, this interval can be changed. However, be aware that each scheduled jobs' next occurence gets calculated on every tick. scheduleTimer.Interval = 1000; scheduleTimer.Start(); checkForJobEnqueue = true; eventTimer.Interval = 100; eventTimer.Start(); serviceStatus = ServiceStatus.Running; return(true); } else if (serviceStatus == ServiceStatus.Paused) { return(Resume()); } return(false); }
public TaskDispatcher(byte maxConcurrency, IExecutionQueue[] executionQueues) { if (maxConcurrency == 0) { throw new ArgumentOutOfRangeException("maxConcurrency", "MaxConcurrency should be greater than zero."); } if (executionQueues == null) { throw new ArgumentNullException("executionQueues"); } if (executionQueues.Length == 0) { throw new ArgumentOutOfRangeException("executionQueues", "List of execution queues cannot be empty."); } if (executionQueues.Any(x => x == null)) { throw new ArgumentOutOfRangeException("executionQueues", "Execution queues cannot contain null values."); } var queueTotalConcurrency = (byte)executionQueues.Sum(x => x.MaxConcurrency); _maxConcurrency = Math.Min(maxConcurrency, queueTotalConcurrency); _executionQueues = executionQueues.OrderByDescending(x => x.Priority).ToArray(); _executionInfos = new ExecutionInfo[_maxConcurrency]; _threadNames = Enumerable.Range(0, _maxConcurrency).Select(x => "DarkFlow#" + x).ToArray(); foreach (var executionQueue in executionQueues) { executionQueue.TaskAdded += OnTaskAdded; } Thread.MemoryBarrier(); }
private void OnTaskAdded(IExecutionQueue executor) { Contract.Require(executor != null, "executor != null"); TryStartNewThread(executor); }
private void TryStartNewThread(IExecutionQueue executor) { BEGIN: if (_disposed) return; //Second check to ensure concurrency threshold would not be exceeded. var currentConcurrency = Interlocked.Increment(ref _currentConcurrency); if (currentConcurrency > _maxConcurrency) { currentConcurrency = Interlocked.Decrement(ref _currentConcurrency); if (currentConcurrency == 0) { goto BEGIN; } return; } ExecutionEnvelope envelope; if (executor == null) { envelope = TakeNextTask(); } else { envelope = executor.Dequeue(); } if (envelope == null) { Interlocked.Decrement(ref _currentConcurrency); return; } if (Logger.IsDebugEnabled) { Logger.Debug("Starting new execution thread."); } var executionInfo = new ExecutionInfo { CurrentTask = envelope }; var tplTask = new Task(PerformTasks, executionInfo); executionInfo.TakeFreeCell(_executionInfos, _threadNames); executionInfo.TplTask = tplTask; tplTask.Start(); }
public IconService(IExecutionQueue queue) { _queue = queue; }
internal JobExecutionContext(JobContext jobContext, IExecutionQueue executionQueue, Thread thread) : this(jobContext, executionQueue) { Thread = thread; }
internal JobExecutionContext(JobContext jobContext, IExecutionQueue executionQueue) { JobContext = jobContext; ExecutionQueue = executionQueue; }
public QueuedItemFactory(IExecutionQueue queue, IScreenConductor shell) { _queue = queue; _shell = shell; }