Esempio n. 1
0
        internal Status UpdateIndex()
        {
            UpdateJob proposedJob = Storage.CreateUpdateJob(ViewsInGroup().Select(x => x.Storage));
            UpdateJob nextJob     = null;
            var       updateQueue = _UpdateQueueFactory.ListForGroup(GroupName());

            updateQueue.Lock();
            try {
                if (updateQueue.Count > 0)
                {
                    nextJob = updateQueue.FirstOrDefault(x => x.Equals(proposedJob));
                    if (nextJob == null)
                    {
                        QueueUpdate(proposedJob);
                        nextJob = proposedJob;
                    }
                }
                else
                {
                    QueueUpdate(proposedJob);
                    nextJob = proposedJob;
                    nextJob.Run();
                }
            } finally {
                updateQueue.Unlock();
            }

            nextJob.Wait();
            return(nextJob.Result);
        }
Esempio n. 2
0
        internal Status UpdateIndex()
        {
            //TODO: View grouping
            var viewsToUpdate = new List <IViewStore> {
                Storage
            };

            UpdateJob proposedJob = Storage.CreateUpdateJob(viewsToUpdate);
            UpdateJob nextJob     = null;

            if (_updateQueue.TryPeek(out nextJob))
            {
                if (!nextJob.LastSequences.SequenceEqual(proposedJob.LastSequences))
                {
                    QueueUpdate(proposedJob);
                    nextJob = proposedJob;
                }
            }
            else
            {
                QueueUpdate(proposedJob);
                nextJob = proposedJob;
            }

            nextJob.Wait();
            return(nextJob.Result);
        }
Esempio n. 3
0
        private UpdateJob QueueUpdate(UpdateJob job)
        {
            job.Finished += (sender, e) => {
                UpdateJob nextJob;
                _updateQueue.TryDequeue(out nextJob);
                if (_updateQueue.TryPeek(out nextJob))
                {
                    nextJob.Run();
                }
            };

            _updateQueue.Enqueue(job);
            if (_updateQueue.Count == 1)
            {
                job.Run();
            }

            return(job);
        }
Esempio n. 4
0
        private UpdateJob QueueUpdate(UpdateJob job)
        {
            var updateQueue = _UpdateQueueFactory.ListForGroup(GroupName());

            job.Finished += (sender, e) => {
                updateQueue.Lock();
                try {
                    updateQueue.RemoveFirst();
                    if (updateQueue.Count > 0)
                    {
                        updateQueue.First.Value.Run();
                    }
                } finally {
                    updateQueue.Unlock();
                }
            };

            updateQueue.AddLast(job);

            return(job);
        }
Esempio n. 5
0
        internal Status UpdateIndex()
        {
            var viewsToUpdate = ViewsInGroup();

            UpdateJob proposedJob = Storage.CreateUpdateJob(viewsToUpdate);
            UpdateJob nextJob     = null;

            if (_updateQueue.TryPeek(out nextJob))
            {
                if (!nextJob.LastSequences.SequenceEqual(proposedJob.LastSequences))
                {
                    QueueUpdate(proposedJob);
                    nextJob = proposedJob;
                }
            }
            else
            {
                QueueUpdate(proposedJob);
                nextJob = proposedJob;
            }

            nextJob.Wait();
            return(nextJob.Result);
        }