{}
void CommitPackageCache::setCommitList( std::vector<sat::Solvable> commitList_r )
- {
- _pimpl->setCommitList( commitList_r );
- }
+ { _pimpl->setCommitList( commitList_r ); }
ManagedFile CommitPackageCache::get( const PoolItem & citem_r )
{ return _pimpl->get( citem_r ); }
+ bool CommitPackageCache::preloaded() const
+ { return _pimpl->preloaded(); }
+
+ void CommitPackageCache::preloaded( bool newval_r )
+ { _pimpl->preloaded( newval_r ); }
+
/******************************************************************
**
** FUNCTION NAME : operator<<
ManagedFile get( sat::Solvable citem_r )
{ return get( PoolItem(citem_r) ); }
+ /** Whether preloaded hint is set.
+ * If preloaded the cache tries to avoid trigering the infoInCache CB,
+ * based on the assumption this was already done when preloading the cache.
+ */
+ bool preloaded() const;
+ /** Set preloaded hint. */
+ void preloaded( bool newval_r );
+
public:
/** Implementation. */
class Impl;
const std::vector<sat::Solvable> & commitList() const
{ return _commitList; }
+ bool preloaded() const
+ { return _preloaded; }
+
+ void preloaded( bool newval_r )
+ { _preloaded = newval_r; }
+
protected:
/** Let the Source provide the package. */
virtual ManagedFile sourceProvidePackage( const PoolItem & pi ) const
private:
std::vector<sat::Solvable> _commitList;
PackageProvider _packageProvider;
+ DefaultIntegral<bool,false> _preloaded;
};
///////////////////////////////////////////////////////////////////
//
ManagedFile CommitPackageCacheReadAhead::get( const PoolItem & citem_r )
{
- // Non CD/DVD media provide their packages without cache.
- if ( ! onInteractiveMedia( citem_r ) )
+ ManagedFile ret;
+ if ( preloaded() )
{
- return sourceProvidePackage( citem_r );
+ // Check whether it's cached.
+ ManagedFile ret( sourceProvideCachedPackage( citem_r ) );
+ if ( ! ret->empty() )
+ return ret;
}
+ // else: we head for sourceProvidePackage(), even if the package
+ // was cached. The actual difference is that sourceProvidePackage
+ // will trigger the infoInCache CB that informs the application.
+ // Once the cache is preloaded we try to avoid this CB.
- // Check whether it's cached.
- ManagedFile ret( sourceProvideCachedPackage( citem_r ) );
- if ( ! ret->empty() )
- return ret;
- IMediaKey current( citem_r );
- if ( current != _lastInteractive )
+ // Preload cache if a CD/DVD change is pending to avoid
+ // switching back and forth...
+ if ( onInteractiveMedia( citem_r ) )
{
- if ( _lastInteractive != IMediaKey() )
+ ret = sourceProvideCachedPackage( citem_r );
+ if ( ! ret->empty() )
+ return ret;
+
+ IMediaKey current( citem_r );
+ if ( current != _lastInteractive )
{
- cacheLastInteractive( citem_r );
- }
+ if ( _lastInteractive != IMediaKey() )
+ {
+ cacheLastInteractive( citem_r );
+ }
- DBG << "Interactive change [" << ++_dbgChanges << "] from " << _lastInteractive << " to " << current << endl;
- _lastInteractive = current;
+ DBG << "Interactive change [" << ++_dbgChanges << "] from " << _lastInteractive << " to " << current << endl;
+ _lastInteractive = current;
+ }
}
// Provide and return the file from media.