Ejemplo n.º 1
0
        public void Queue <T>(QueueGroupKey <T> queueGroupKey, IEnumerable <T> items)
        {
            lock (queueGroupKeyToExecutionTimeDict)
            {
                QueueGroup queueGroup = DictionaryExtension.ValueOrDefault(queueGroupKeyToExecutionTimeDict, queueGroupKey);
                if (queueGroup != null)
                {
                    // Runnable already pending with given QueueGroupKey
                    IList queue2 = queueGroup.Queue;
                    foreach (T item in items)
                    {
                        queue2.Add(item);
                    }
                    return;
                }
                queueGroup = new QueueGroup(queueGroupKey, new List <T>());
                queueGroupKeyToExecutionTimeDict.Add(queueGroupKey, queueGroup);

                IList queue = queueGroup.Queue;
                foreach (T item in items)
                {
                    queue.Add(item);
                }
                QueueIntern <T>(queueGroup);
            }
        }
Ejemplo n.º 2
0
        public void Queue(QueueGroupKey queueGroupKey)
        {
            lock (queueGroupKeyToExecutionTimeDict)
            {
                QueueGroup queueGroup = DictionaryExtension.ValueOrDefault(queueGroupKeyToExecutionTimeDict, queueGroupKey);
                if (queueGroup != null)
                {
                    // Runnable already pending with given QueueGroupKey
                    return;
                }
                queueGroup = new QueueGroup(queueGroupKey);

                queueGroupKeyToExecutionTimeDict.Add(queueGroupKey, queueGroup);
                bool queueGroupAdded = false;

                // Insert the QueueGroup at the right position of pending QueueGroups
                // At index 0 is the latest of all, at max-index the next triggering QueueGroup
                for (int a = 0, size = pendingQueueGroups.Count; a < size; a++)
                {
                    QueueGroup pendingQueueGroup = pendingQueueGroups[a];
                    if (queueGroup.ExecutionTime >= pendingQueueGroup.ExecutionTime)
                    {
                        // If new QueueGroup executes AFTER or EQUAL TO the current investigated QueueGroup,
                        // insert the new QueueGroup BEFORE in the list
                        pendingQueueGroups.Insert(a, queueGroup);
                        queueGroupAdded = true;
                        break;
                    }
                }
                if (!queueGroupAdded)
                {
                    pendingQueueGroups.Add(queueGroup);
                }
            }
        }
Ejemplo n.º 3
0
        public void Queue <T>(QueueGroupKey <T> queueGroupKey, T item)
        {
            lock (queueGroupKeyToExecutionTimeDict)
            {
                QueueGroup queueGroup = DictionaryExtension.ValueOrDefault(queueGroupKeyToExecutionTimeDict, queueGroupKey);
                if (queueGroup != null)
                {
                    // Runnable already pending with given QueueGroupKey
                    queueGroup.Queue.Add(item);
                    return;
                }
                queueGroup = new QueueGroup(queueGroupKey, new List <T>());
                queueGroupKeyToExecutionTimeDict.Add(queueGroupKey, queueGroup);

                queueGroup.Queue.Add(item);
                QueueIntern <T>(queueGroup);
            }
        }