コード例 #1
0
        static void ConsumeParsingQueue()
        {
            int pending = 0;
            IProgressMonitor monitor = null;

            try {
                Set <ProjectDom> dbsToFlush = new Set <ProjectDom> ();
                do
                {
                    if (pending > 5 && monitor == null)
                    {
                        monitor = GetParseProgressMonitor();
                        monitor.BeginTask(GettextCatalog.GetString("Generating database"), 0);
                    }

                    ParsingJob job = DequeueParseJob();

                    if (job != null)
                    {
                        try {
                            job.ParseCallback(job.File, monitor);
                            if (job.Database != null)
                            {
                                dbsToFlush.Add(job.Database);
                            }
                        } catch (Exception ex) {
                            if (monitor == null)
                            {
                                monitor = GetParseProgressMonitor();
                            }
                            monitor.ReportError(null, ex);
                        }
                    }

                    pending = PendingJobCount;
                }while (pending > 0);

                queueEmptied.Set();

                // Flush the parsed databases
                foreach (ProjectDom db in dbsToFlush)
                {
                    db.Flush();
                }
            } finally {
                if (monitor != null)
                {
                    monitor.Dispose();
                }
            }
        }
コード例 #2
0
 static ParsingJob DequeueParseJob()
 {
     lock (parseQueueLock)
     {
         while (parseQueue.Count > 0)
         {
             ParsingJob job = parseQueue.Dequeue();
             if (job.ParseCallback != null)
             {
                 parseQueueIndex.Remove(job.File);
                 return(job);
             }
         }
         return(null);
     }
 }
コード例 #3
0
        public static void QueueParseJob(ProjectDom db, Action <string, IProgressMonitor> callback, string file)
        {
            ParsingJob job = new ParsingJob();

            job.ParseCallback = callback;
            job.File          = file;
            job.Database      = db;
            lock (parseQueueLock)
            {
                RemoveParseJob(file);
                parseQueueIndex [file] = job;
                parseQueue.Enqueue(job);
                parseEvent.Set();

                if (parseQueueIndex.Count == 1)
                {
                    queueEmptied.Reset();
                }
            }
        }
コード例 #4
0
		public static void QueueParseJob (ProjectDom db, Action<string, IProgressMonitor> callback, string file)
		{
			ParsingJob job = new ParsingJob ();
			job.ParseCallback = callback;
			job.File = file;
			job.Database = db;
			lock (parseQueueLock)
			{
				RemoveParseJob (file);
				parseQueueIndex [file] = job;
				parseQueue.Enqueue (job);
				parseEvent.Set ();
				
				if (parseQueueIndex.Count == 1)
					queueEmptied.Reset ();
			}
		}
コード例 #5
0
 internal void QueueParseJob(JobCallback callback, object data)
 {
     ParsingJob job = new ParsingJob ();
     job.ParseCallback = callback;
     job.Data = data;
     lock (parseQueue)
     {
         parseQueue.Enqueue (job);
         parseEvent.Set ();
     }
 }