[Aptitude-svn-commit] r4119 - in branches/aptitude-0.3/aptitude: . src/generic/problemresolver

Daniel Burrows dburrows at costa.debian.org
Tue Sep 20 00:00:58 UTC 2005


Author: dburrows
Date: Tue Sep 20 00:00:55 2005
New Revision: 4119

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h
Log:
Add code to allow users of the resolver to check its queue sizes.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Tue Sep 20 00:00:55 2005
@@ -1,5 +1,10 @@
 2005-09-19  Daniel Burrows  <dburrows at debian.org>
 
+	* src/generic/problemresolver/problemresolver.h:
+
+	  Allow users of the resolver to check the size of its various
+	  queues.
+
 	* src/generic/resolver_manager.cc:
 
 	  Indicate that the background thread left the resolver before

Modified: branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/problemresolver/problemresolver.h	Tue Sep 20 00:00:55 2005
@@ -178,6 +178,20 @@
 
   typedef typename solution::action action;
 
+  /** Information about the sizes of the various resolver queues. */
+  struct queue_counts
+  {
+    size_t open;
+    size_t closed;
+    size_t deferred;
+    size_t conflicts;
+
+    queue_counts()
+      : open(0), closed(0), deferred(0), conflicts(0)
+    {
+    }
+  };
+
 private:
   /** Hash function for packages: */
   struct ExtractPackageId
@@ -348,11 +362,18 @@
     */
    bool solver_cancelled : 1;
 
-   /** Mutex guarding the solver_executing and stop_solver. */
+   /** Mutex guarding the solver_executing and stop_solver variables. */
    threads::mutex execution_mutex;
 
 
 
+   queue_counts counts;
+
+   /** Mutex guarding the cache of resolver status information. */
+   threads::mutex counts_mutex;
+
+
+
    /** The working queue: */
    std::priority_queue<solution, std::vector<solution>, solution_goodness_compare> open;
 
@@ -2163,6 +2184,13 @@
     solver_cancelled = false;
   }
 
+  /** Atomically read the current queue sizes of this resolver. */
+  queue_counts get_counts()
+  {
+    threads::mutex::lock l(counts_mutex);
+    return counts;
+  }
+
   /** Try to find the "next" solution: remove partial solutions from
    *  the open queue and place them in the closed queue until one of
    *  the following occurs:
@@ -2224,6 +2252,15 @@
 	    throw InterruptedException();
 	}
 
+	// Update the cached queue sizes.
+	{
+	  threads::mutex::lock l(counts_mutex);
+	  counts.open      = open.size();
+	  counts.closed    = closed.size();
+	  counts.deferred  = deferred.size();
+	  counts.conflicts = conflicts.size();
+	}
+
 
 	solution s=open.top();
 	open.pop();



More information about the Aptitude-svn-commit mailing list