New problem solution added: Unlock ALL resovables in order to speed up
authorStefan Schubert <schubi@suse.de>
Fri, 3 Nov 2006 10:05:00 +0000 (10:05 +0000)
committerStefan Schubert <schubi@suse.de>
Fri, 3 Nov 2006 10:05:00 +0000 (10:05 +0000)
problem solution. Bug 206453

zypp/solver/detail/ProblemSolutionUnlock.cc
zypp/solver/detail/ProblemSolutionUnlock.h
zypp/solver/detail/Resolver_problems.cc

index 8a98c7d..0040ec5 100644 (file)
 
 #include "zypp/base/String.h"
 #include "zypp/base/Gettext.h"
+#include "zypp/base/Algorithm.h"
+#include "zypp/ResPool.h"
+#include "zypp/ResFilters.h"
+#include "zypp/CapFilters.h"
 #include "zypp/solver/detail/ProblemSolutionUnlock.h"
 
 using namespace std;
@@ -44,11 +48,31 @@ IMPL_PTR_TYPE(ProblemSolutionUnlock);
 
 //---------------------------------------------------------------------------
 
-ProblemSolutionUnlock::ProblemSolutionUnlock( ResolverProblem_Ptr parent)
+struct LockReset : public resfilter::PoolItemFilterFunctor
+{
+    ProblemSolutionUnlock & _problemSolutionUnlock;
+    LockReset( ProblemSolutionUnlock & solution )
+       : _problemSolutionUnlock( solution )
+    { }
+
+    bool operator()( PoolItem_Ref item )
+    {
+       _problemSolutionUnlock.addAction ( new TransactionSolutionAction (item, UNLOCK));       
+       return true;
+    }
+};
+
+       
+ProblemSolutionUnlock::ProblemSolutionUnlock( ResolverProblem_Ptr parent,
+                                             const ResPool & pool)
     : ProblemSolution (parent, "", "")
 {
     _description = _("unlock all resolvables");
-#warning implementation of unlocking ALL items
+    LockReset lockReset (*this);
+
+    invokeOnEach ( pool.begin(), pool.end(),
+                  resfilter::ByLock( ),
+                  functor::functorRef<bool,PoolItem>(lockReset));
 }
        
 ProblemSolutionUnlock::ProblemSolutionUnlock( ResolverProblem_Ptr parent,
index 0903939..a563992 100644 (file)
@@ -49,7 +49,7 @@ namespace zypp
             **/
            ProblemSolutionUnlock( ResolverProblem_Ptr parent, PoolItem_Ref item);
            ProblemSolutionUnlock( ResolverProblem_Ptr parent, PoolItemList & itemlist);
-           ProblemSolutionUnlock( ResolverProblem_Ptr parent);     
+           ProblemSolutionUnlock( ResolverProblem_Ptr parent, const ResPool & pool);       
        };
 
       ///////////////////////////////////////////////////////////////////
index 5ff2d17..0677558 100644 (file)
@@ -517,6 +517,8 @@ Resolver::problems (void) const
                    if (it->second.matches (misc_info->capability()) == CapMatch::yes) {
                        // unlock this item
                        problem->addSolution (new ProblemSolutionUnlock (problem, it->first));
+                       // unlock ALL existing resolvables
+                       problem->addSolution (new ProblemSolutionUnlock (problem, pool()));                     
                    }
                }
                // Searching for another item which provides this requires BUT has another architec
@@ -641,6 +643,8 @@ Resolver::problems (void) const
                
                ResolverProblem_Ptr problem = new ResolverProblem (what, details);
                problem->addSolution (new ProblemSolutionUnlock (problem, item)); // Unlocking resItem
+               // unlock ALL existing resolvables
+               problem->addSolution (new ProblemSolutionUnlock (problem, pool()));                                     
                if (misc_info->trigger() == ResolverInfoMisc::OBSOLETE) {
                    // Ignore obsoletes
                    problem->addSolution (new ProblemSolutionIgnoreObsoletes (problem, item, misc_info->capability(),