/// <summary> /// Filters and executes the commands until multi queue getting full again and or command is new is queue /// </summary> private void _FilterAndExecuteCommands(ThreadSafeMultiQueue <string, IDBCommand> multiQueue, CommandPriority currentPriority) { bool queueTooLoaded = multiQueue.Count() > ct_queueThreshold; while (_commandsToExecute.Count > 0) { if (_GetHighestNonEmptyPriority() < currentPriority) { return; } if (queueTooLoaded) { //if filtering process began when queue was too loaded or there is blocking command in queue //all commands that passed in the filter will be executed regardless of //how much time they were in queue _ExecuteCommand(_commandsToExecute.Dequeue()); } else if (_MinimumCommandQueueTime.HasValue) { //If commands was not in queue for enough time the execution process is halted IDBCommand nextCommand = _commandsToExecute.Peek(); DateTime filterThreshold = nextCommand.GetQueueInsertionTime() + _MinimumCommandQueueTime.Value; if (_lastFilterEndTime < filterThreshold) { return; } _ExecuteCommand(_commandsToExecute.Dequeue()); } else { throw new GatDataBaseException( "filterAndExecuteCommands was called when queueTooLoaded = false and !parameters.MinimumCommandQueueTime.HasValue"); } //If queue is getting loaded the execution process is halted if (multiQueue.Count() >= ct_queueThreshold) { return; } } }
private void _ExecuteNonFilteredQueue(ThreadSafeMultiQueue <string, IDBCommand> multiQueue, CommandPriority currentPriority) { while (multiQueue.Count() > 0) { foreach (IDBCommand command in multiQueue) { _ExecuteCommand(command); if (_GetHighestNonEmptyPriority() < currentPriority) { break; } } } GatLogger.Instance.AddMessage("DB Queue is empty. You can exit at anytime.", LogMode.LogAndScreen); }