[Aptitude-svn-commit] r4061 - in branches/aptitude-0.3/aptitude: .
src
Daniel Burrows
dburrows at costa.debian.org
Tue Sep 6 23:40:17 UTC 2005
Author: dburrows
Date: Tue Sep 6 23:40:12 2005
New Revision: 4061
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/ui.cc
Log:
Move package downloads to a background thread.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Tue Sep 6 23:40:12 2005
@@ -1,5 +1,9 @@
2005-09-06 Daniel Burrows <dburrows at debian.org>
+ * src/ui.cc:
+
+ Move package downloads to a background thread.
+
* src/generic/setset.h:
Significantly speed up the operation of find_subset by
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 Tue Sep 6 23:40:12 2005
@@ -833,6 +833,14 @@
};
+static void finish_install_or_remove_packages(download_thread *t,
+ pkgAcquire::RunResult res,
+ pkgAcquire *acq,
+ pkgPackageManager *pm,
+ download_manager *m,
+ background_status *st,
+ downloader *abort_state);
+
void install_or_remove_packages()
{
active_download=true;
@@ -842,7 +850,7 @@
vs_progress_ref p = gen_progress_bar();
- downloader abort_state;
+ downloader *abort_state = new downloader;
download_manager *m = gen_download_progress(false,
_("Downloading packages"),
@@ -853,28 +861,49 @@
pkgAcquire *acq;
pkgPackageManager *pm;
+ background_status *st = new background_status(m);
bool ok = prepare_install_run(p.unsafe_get_ref(),
- false, false, m, acq, pm);
+ false, false, st, acq, pm);
+
+ p->destroy();
if(ok)
- {
- install_run_result run_res;
+ (new download_thread(acq,
+ sigc::bind(sigc::ptr_fun(&finish_install_or_remove_packages),
+ acq, pm, m, st, abort_state)))->start();
+}
- do
- {
- pkgAcquire::RunResult res = acq->Run();
- run_res = finish_install_run(p.unsafe_get_ref(),
- false, false, m,
- acq, pm, res);
- } while(run_res == install_do_again &&
- !abort_state.get_aborted());
- }
+static void finish_install_or_remove_packages(download_thread *t,
+ pkgAcquire::RunResult res,
+ pkgAcquire *acq,
+ pkgPackageManager *pm,
+ download_manager *m,
+ background_status *st,
+ downloader *abort_state)
+{
+ vs_progress_ref p = gen_progress_bar();
+
+ install_run_result run_res = finish_install_run(p.unsafe_get_ref(),
+ false, false, m,
+ acq, pm, res);
- delete acq;
- delete pm;
p->destroy();
- active_download=false;
+ delete t;
+
+ if(run_res == install_do_again && !abort_state->get_aborted())
+ (new download_thread(acq,
+ sigc::bind(sigc::ptr_fun(&finish_install_or_remove_packages),
+ acq, pm, m, st, abort_state)))->start();
+ else
+ {
+ delete acq;
+ delete pm;
+ delete st;
+ delete abort_state;
+
+ active_download=false;
+ }
}
/** Make sure that no trust violations are about to be committed. If
More information about the Aptitude-svn-commit
mailing list