[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
|
||||
JobQueue::enqueue( const job_ptr& job )
|
||||
{
|
||||
Q_ASSERT( !m_thread->isRunning() );
|
||||
m_jobs.append( job );
|
||||
emit queueChanged( m_jobs );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
JobQueue::enqueue( const JobList& jobs )
|
||||
JobQueue::enqueue( int moduleWeight, const JobList& jobs )
|
||||
{
|
||||
Q_ASSERT( !m_thread->isRunning() );
|
||||
m_jobs.append( jobs );
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
||||
*
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac <teo@kde.org>
|
||||
*
|
||||
* Calamares is free software: you can redistribute it and/or modify
|
||||
@ -30,7 +30,6 @@
|
||||
|
||||
namespace Calamares
|
||||
{
|
||||
|
||||
class GlobalStorage;
|
||||
class JobThread;
|
||||
|
||||
@ -45,8 +44,12 @@ public:
|
||||
|
||||
GlobalStorage* globalStorage() const;
|
||||
|
||||
void enqueue( const job_ptr& job );
|
||||
void enqueue( const JobList& jobs );
|
||||
/** @brief Queues up jobs from a single module source
|
||||
*
|
||||
* 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();
|
||||
|
||||
bool isRunning() const { return !m_finished; }
|
||||
|
@ -71,6 +71,16 @@ public:
|
||||
*/
|
||||
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.
|
||||
* @param instanceKey the instance key for a module instance.
|
||||
|
@ -146,10 +146,24 @@ ExecutionViewStep::onActivate()
|
||||
{
|
||||
m_slideshow->changeSlideShowState( Slideshow::Start );
|
||||
|
||||
const auto instanceDescriptors = Calamares::Settings::instance()->moduleInstances();
|
||||
|
||||
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 );
|
||||
|
||||
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 )
|
||||
{
|
||||
auto jl = module->jobs();
|
||||
@ -160,7 +174,7 @@ ExecutionViewStep::onActivate()
|
||||
j->setEmergency( true );
|
||||
}
|
||||
}
|
||||
queue->enqueue( jl );
|
||||
queue->enqueue( weight, jl );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user