[Aptitude-svn-commit] r4162 - in branches/aptitude-0.3/aptitude: .
src src/cmdline src/generic
Daniel Burrows
dburrows at costa.debian.org
Wed Sep 21 22:58:52 UTC 2005
Author: dburrows
Date: Wed Sep 21 22:58:49 2005
New Revision: 4162
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/broken_indicator.cc
branches/aptitude-0.3/aptitude/src/cmdline/cmdline_resolver.cc
branches/aptitude-0.3/aptitude/src/generic/resolver_manager.cc
branches/aptitude-0.3/aptitude/src/generic/resolver_manager.h
branches/aptitude-0.3/aptitude/src/solution_dialog.cc
branches/aptitude-0.3/aptitude/src/solution_screen.cc
branches/aptitude-0.3/aptitude/src/ui.cc
Log:
Make the search time limit an explicit parameter of get_*_solution.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Wed Sep 21 22:58:49 2005
@@ -1,5 +1,10 @@
2005-09-21 Daniel Burrows <dburrows at debian.org>
+ * src/broken_indicator.cc, src/cmdline/cmdline_resolver.cc, src/generic/resolver_manager.cc, src/generic/resolver_manager.h, src/solution_dialog.cc, src/solution_screen.cc, src/ui.cc:
+
+ Make the number of steps an explicit parameter to get_solution
+ and get_solution_background.
+
* src/ui.cc:
Signal that the resolver state changed when it runs out of
Modified: branches/aptitude-0.3/aptitude/src/broken_indicator.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/broken_indicator.cc (original)
+++ branches/aptitude-0.3/aptitude/src/broken_indicator.cc Wed Sep 21 22:58:49 2005
@@ -251,7 +251,7 @@
return;
}
- aptitude_solution sol = resman->get_solution(state.selected_solution);
+ aptitude_solution sol = resman->get_solution(state.selected_solution, 0);
// This test always fails the first time update() is called, since
// sol is never NULL and last_sol is initialized to NULL.
Modified: branches/aptitude-0.3/aptitude/src/cmdline/cmdline_resolver.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/cmdline/cmdline_resolver.cc (original)
+++ branches/aptitude-0.3/aptitude/src/cmdline/cmdline_resolver.cc Wed Sep 21 22:58:49 2005
@@ -405,7 +405,7 @@
aptitude_solution calculate_current_solution()
{
if(resman->get_selected_solution() < resman->generated_solution_count())
- return resman->get_solution(resman->get_selected_solution());
+ return resman->get_solution(resman->get_selected_solution(), 0);
cmdline_spinner spin;
@@ -415,6 +415,7 @@
threads::box<cmdline_resolver_continuation::resolver_result> retbox;
resman->get_solution_background(resman->generated_solution_count(),
+ aptcfg->FindI(PACKAGE "::ProblemResolver::StepLimit", 5000),
new cmdline_resolver_continuation(retbox));
cmdline_resolver_continuation::resolver_result res;
Modified: branches/aptitude-0.3/aptitude/src/generic/resolver_manager.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/resolver_manager.cc (original)
+++ branches/aptitude-0.3/aptitude/src/generic/resolver_manager.cc Wed Sep 21 22:58:49 2005
@@ -93,7 +93,7 @@
// FIXME: max_steps should be changed when the configuration is (not a
// visible bug at the moment since you can't change that option
// interactively)
-void resolver_manager::background_thread_execution(int max_steps)
+void resolver_manager::background_thread_execution()
{
threads::mutex::lock l(background_control_mutex);
@@ -114,7 +114,7 @@
try
{
- aptitude_resolver::solution *sol = do_get_solution(max_steps,
+ aptitude_resolver::solution *sol = do_get_solution(job.max_steps,
job.sol_num);
// Set the state variable BEFORE exiting the resolver; this
@@ -170,18 +170,16 @@
// Need this because sigc slots aren't threadsafe :-(
struct resolver_manager::background_thread_bootstrap
{
- int max_steps;
resolver_manager &m;
public:
- background_thread_bootstrap(int _max_steps,
- resolver_manager &_m)
- :max_steps(_max_steps), m(_m)
+ background_thread_bootstrap(resolver_manager &_m)
+ :m(_m)
{
}
void operator()()
{
- m.background_thread_execution(max_steps);
+ m.background_thread_execution();
}
};
@@ -190,7 +188,7 @@
threads::mutex::lock l(mutex);
if(resolver_thread == NULL)
- resolver_thread = new threads::thread(background_thread_bootstrap(aptcfg->FindI(PACKAGE "::ProblemResolver::StepLimit", 5000), *this));
+ resolver_thread = new threads::thread(background_thread_bootstrap(*this));
}
void resolver_manager::kill_background_thread()
@@ -215,7 +213,7 @@
// Reset the associated data structures.
control_lock.acquire();
- pending_jobs = std::priority_queue<job_request, std::vector<job_request>, job_request_sol_num_compare>();
+ pending_jobs = std::priority_queue<job_request, std::vector<job_request>, job_request_compare>();
background_thread_killed = false;
background_thread_suspend_count = 0;
background_thread_in_resolver = false;
@@ -450,7 +448,7 @@
return rval;
}
-aptitude_resolver::solution *resolver_manager::do_get_solution(unsigned int max_steps, unsigned int solution_num)
+aptitude_resolver::solution *resolver_manager::do_get_solution(int max_steps, unsigned int solution_num)
{
threads::mutex::lock sol_l(solutions_mutex);
if(solution_num < solutions.size())
@@ -540,7 +538,8 @@
}
};
-const aptitude_resolver::solution &resolver_manager::get_solution(unsigned int solution_num)
+const aptitude_resolver::solution &resolver_manager::get_solution(unsigned int solution_num,
+ int max_steps)
{
threads::mutex::lock l(mutex);
@@ -559,7 +558,7 @@
threads::mutex m;
threads::condition c;
- get_solution_background(solution_num, new solution_return_continuation(sol, oot, oos, m, c));
+ get_solution_background(solution_num, max_steps, new solution_return_continuation(sol, oot, oos, m, c));
threads::mutex::lock cond_l(m);
while(!sol && !oot && !oos)
@@ -574,6 +573,7 @@
}
void resolver_manager::get_solution_background(unsigned int solution_num,
+ int max_steps,
background_continuation *k)
{
threads::mutex::lock l(mutex);
@@ -593,7 +593,7 @@
threads::mutex::lock control_lock(background_control_mutex);
- pending_jobs.push(job_request(solution_num, k));
+ pending_jobs.push(job_request(solution_num, max_steps, k));
background_control_cond.wake_all();
}
Modified: branches/aptitude-0.3/aptitude/src/generic/resolver_manager.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/resolver_manager.h (original)
+++ branches/aptitude-0.3/aptitude/src/generic/resolver_manager.h Wed Sep 21 22:58:49 2005
@@ -130,21 +130,25 @@
/** The solution number to be calculated. */
int sol_num;
+ /** The number of steps to allow for this calculation. */
+ int max_steps;
+
/** The continuation of this computation. */
background_continuation *k;
- job_request(int _sol_num, background_continuation *_k)
- :sol_num(_sol_num), k(_k)
+ job_request(int _sol_num, int _max_steps, background_continuation *_k)
+ :sol_num(_sol_num), max_steps(_max_steps), k(_k)
{
}
};
- /** Sort job requests by their solution number. */
- struct job_request_sol_num_compare
+ /** Sort job requests by their solution number and step count. */
+ struct job_request_compare
{
bool operator()(const job_request &jr1, const job_request &jr2) const
{
- return jr1.sol_num < jr2.sol_num;
+ return jr1.sol_num < jr2.sol_num ||
+ (jr1.sol_num == jr2.sol_num && jr1.max_steps < jr2.max_steps);
}
};
@@ -180,7 +184,7 @@
/** The pending job requests for the background thread.
*/
std::priority_queue<job_request, std::vector<job_request>,
- job_request_sol_num_compare> pending_jobs;
+ job_request_compare> pending_jobs;
/** If \b true, the background thread should abort its execution. */
bool background_thread_killed;
@@ -249,15 +253,10 @@
* the foreground or in the background. It is called by
* background_thread_execution and get_solution.
*/
- generic_solution<aptitude_universe> *do_get_solution(unsigned int max_Steps, unsigned int solution_number);
+ generic_solution<aptitude_universe> *do_get_solution(int max_steps, unsigned int solution_number);
- /** The actual background thread.
- *
- * \param max_steps the limit of this thread's search
- * \param sol_num the number of solutions to be examined by this
- * thread.
- */
- void background_thread_execution(int max_steps);
+ /** The actual background thread. */
+ void background_thread_execution();
/** Start a background thread if none exists. */
void start_background_thread();
@@ -327,17 +326,20 @@
* \throw ResolverManagerThreadClashException if a new solution
* would be generated and a background thread exists.
*/
- const generic_solution<aptitude_universe> &get_solution(unsigned int solution_num);
+ const generic_solution<aptitude_universe> &get_solution(unsigned int solution_num,
+ int max_steps);
/** As get_solution, but run in a background thread if necessary.
*
* \param solution_num the solution to retrieve
*
+ * \param max_steps the number of steps to allow the computation
+ *
* \param k a background_continuation object; when the background
* computation is finished, a method corresponding to its result
- * will be invoked on continuation. This method may be invoked in
- * either the foreground thread or the background thread, so it
- * should be threadsafe.
+ * will be invoked on continuation in the background thread. It is
+ * safe for this method to manipulate the resolver (for instance,
+ * to enqueue a new computation).
*
* k is owned by this object and will be deleted at its discretion.
*
@@ -345,6 +347,7 @@
* resolver already exists.
*/
void get_solution_background(unsigned int solution_num,
+ int max_steps,
background_continuation *k);
/** If \b true, all solutions have been generated. */
Modified: branches/aptitude-0.3/aptitude/src/solution_dialog.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/solution_dialog.cc (original)
+++ branches/aptitude-0.3/aptitude/src/solution_dialog.cc Wed Sep 21 22:58:49 2005
@@ -130,7 +130,7 @@
return;
}
- aptitude_solution sol = resman->get_solution(state.selected_solution);
+ aptitude_solution sol = resman->get_solution(state.selected_solution, 0);
if(sol == last_sol)
return;
Modified: branches/aptitude-0.3/aptitude/src/solution_screen.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/solution_screen.cc (original)
+++ branches/aptitude-0.3/aptitude/src/solution_screen.cc Wed Sep 21 22:58:49 2005
@@ -1060,7 +1060,7 @@
return;
}
- aptitude_solution sol = resman->get_solution(state.selected_solution);
+ aptitude_solution sol = resman->get_solution(state.selected_solution, 0);
if(sol == last_sol)
return;
Modified: branches/aptitude-0.3/aptitude/src/ui.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/ui.cc (original)
+++ branches/aptitude-0.3/aptitude/src/ui.cc Wed Sep 21 22:58:49 2005
@@ -1052,7 +1052,7 @@
assert(resman != NULL);
assert(resman->resolver_exists());
- aptitude_solution sol = resman->get_solution(resman->get_selected_solution());
+ aptitude_solution sol = resman->get_solution(resman->get_selected_solution(), 0);
(*apt_cache_file)->apply_solution(sol, undo);
show_message(fragf("%s%n%n%F",
@@ -1452,21 +1452,6 @@
}
};
- class no_more_time_event : public vscreen_event
- {
- resolver_manager *manager;
- public:
- no_more_time_event(resolver_manager *_manager)
- :manager(_manager)
- {
- }
-
- void dispatch()
- {
- start_solution_calculation();
- }
- };
-
class no_more_solutions_event : public vscreen_event
{
resolver_manager *manager;
@@ -1505,7 +1490,7 @@
void no_more_time()
{
- vscreen_post_event(new no_more_time_event(manager));
+ start_solution_calculation();
}
void interrupted()
@@ -1523,6 +1508,7 @@
state.selected_solution == state.generated_solutions &&
!state.background_thread_active)
resman->get_solution_background(resman->get_selected_solution(),
+ aptcfg->FindI(PACKAGE "::ProblemResolver::StepLimit", 5000),
new interactive_continuation(resman));
}
@@ -1561,7 +1547,7 @@
undo_group *undo=new apt_undo_group;
try
{
- (*apt_cache_file)->apply_solution(resman->get_solution(resman->get_selected_solution()),
+ (*apt_cache_file)->apply_solution(resman->get_solution(resman->get_selected_solution(), aptcfg->FindI(PACKAGE "::ProblemResolver::StepLimit", 5000)),
undo);
}
catch(NoMoreSolutions)
More information about the Aptitude-svn-commit
mailing list