[libcalamares] When enqueueing jobs, pass a weight
- The weight is the module (instance) weight, which can be - the default weight of 1 - the weight specified for the module (in module.desc / the module descriptor; this defaults to 1, above) - the weight specified for the instance (in settings.conf) The last of these "wins"; weights are constrained to 1..100 The weight isn't actually used in progress computation yet.
This commit is contained in:
parent
a91ef65a37
commit
c296bcffa3
@ -205,16 +205,7 @@ JobQueue::start()
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
JobQueue::enqueue( const job_ptr& job )
|
JobQueue::enqueue( int moduleWeight, const JobList& jobs )
|
||||||
{
|
|
||||||
Q_ASSERT( !m_thread->isRunning() );
|
|
||||||
m_jobs.append( job );
|
|
||||||
emit queueChanged( m_jobs );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
JobQueue::enqueue( const JobList& jobs )
|
|
||||||
{
|
{
|
||||||
Q_ASSERT( !m_thread->isRunning() );
|
Q_ASSERT( !m_thread->isRunning() );
|
||||||
m_jobs.append( jobs );
|
m_jobs.append( jobs );
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
|
|
||||||
namespace Calamares
|
namespace Calamares
|
||||||
{
|
{
|
||||||
|
|
||||||
class GlobalStorage;
|
class GlobalStorage;
|
||||||
class JobThread;
|
class JobThread;
|
||||||
|
|
||||||
@ -45,8 +44,12 @@ public:
|
|||||||
|
|
||||||
GlobalStorage* globalStorage() const;
|
GlobalStorage* globalStorage() const;
|
||||||
|
|
||||||
void enqueue( const job_ptr& job );
|
/** @brief Queues up jobs from a single module source
|
||||||
void enqueue( const JobList& jobs );
|
*
|
||||||
|
* The total weight of the jobs is spread out to fill the weight
|
||||||
|
* of the module.
|
||||||
|
*/
|
||||||
|
void enqueue( int moduleWeight, const JobList& jobs );
|
||||||
void start();
|
void start();
|
||||||
|
|
||||||
bool isRunning() const { return !m_finished; }
|
bool isRunning() const { return !m_finished; }
|
||||||
|
@ -71,6 +71,16 @@ public:
|
|||||||
*/
|
*/
|
||||||
ModuleSystem::Descriptor moduleDescriptor( const QString& name );
|
ModuleSystem::Descriptor moduleDescriptor( const QString& name );
|
||||||
|
|
||||||
|
/** @brief returns the module descriptor structure for the module @p instance
|
||||||
|
*
|
||||||
|
* Descriptors are for the module, which may have multiple instances;
|
||||||
|
* this is the same as moduleDescriptor( instance.module() ).
|
||||||
|
*/
|
||||||
|
ModuleSystem::Descriptor moduleDescriptor( const ModuleSystem::InstanceKey& instanceKey )
|
||||||
|
{
|
||||||
|
return moduleDescriptor( instanceKey.module() );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief moduleInstance returns a Module object for a given instance key.
|
* @brief moduleInstance returns a Module object for a given instance key.
|
||||||
* @param instanceKey the instance key for a module instance.
|
* @param instanceKey the instance key for a module instance.
|
||||||
|
@ -146,10 +146,24 @@ ExecutionViewStep::onActivate()
|
|||||||
{
|
{
|
||||||
m_slideshow->changeSlideShowState( Slideshow::Start );
|
m_slideshow->changeSlideShowState( Slideshow::Start );
|
||||||
|
|
||||||
|
const auto instanceDescriptors = Calamares::Settings::instance()->moduleInstances();
|
||||||
|
|
||||||
JobQueue* queue = JobQueue::instance();
|
JobQueue* queue = JobQueue::instance();
|
||||||
for( const auto& instanceKey : m_jobInstanceKeys )
|
for ( const auto& instanceKey : m_jobInstanceKeys )
|
||||||
{
|
{
|
||||||
|
const auto& moduleDescriptor = Calamares::ModuleManager::instance()->moduleDescriptor( instanceKey );
|
||||||
Calamares::Module* module = Calamares::ModuleManager::instance()->moduleInstance( instanceKey );
|
Calamares::Module* module = Calamares::ModuleManager::instance()->moduleInstance( instanceKey );
|
||||||
|
|
||||||
|
const auto instanceDescriptor
|
||||||
|
= std::find_if( instanceDescriptors.constBegin(),
|
||||||
|
instanceDescriptors.constEnd(),
|
||||||
|
[=]( const Calamares::InstanceDescription& d ) { return d.key() == instanceKey; } );
|
||||||
|
int weight = moduleDescriptor.weight();
|
||||||
|
if ( instanceDescriptor != instanceDescriptors.constEnd() && instanceDescriptor->explicitWeight() )
|
||||||
|
{
|
||||||
|
weight = instanceDescriptor->weight();
|
||||||
|
}
|
||||||
|
weight = qBound( 1, weight, 100 );
|
||||||
if ( module )
|
if ( module )
|
||||||
{
|
{
|
||||||
auto jl = module->jobs();
|
auto jl = module->jobs();
|
||||||
@ -160,7 +174,7 @@ ExecutionViewStep::onActivate()
|
|||||||
j->setEmergency( true );
|
j->setEmergency( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue->enqueue( jl );
|
queue->enqueue( weight, jl );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user