ConcurrentOperationRunner Class
class QInstaller::ConcurrentOperationRunnerThe ConcurrentOperationRunner class can be used to perform installer operations concurrently. More...
Header: | #include <ConcurrentOperationRunner> |
Public Functions
ConcurrentOperationRunner(OperationList *operations, const Operation::OperationType type, QObject *parent = nullptr) | |
ConcurrentOperationRunner(QObject *parent = nullptr) | |
virtual | ~ConcurrentOperationRunner() |
QHash<Operation *, bool> | run() |
void | setMaxThreadCount(int count) |
void | setOperations(OperationList *operations) |
void | setType(const Operation::OperationType type) |
Public Slots
void | cancel() |
Signals
void | finished() |
void | operationStarted(QInstaller::Operation *operation) |
void | progressChanged(const int completed, const int total) |
Detailed Description
The class accepts an operation list of any registered operation type. It can be used to execute the Backup
, Perform
, or Undo
steps of the operations. The operations are run in a separate thread pool of this class, which by default limits the maximum number of threads to the ideal number of logical processor cores in the system.
Member Function Documentation
ConcurrentOperationRunner::ConcurrentOperationRunner(OperationList *operations, const Operation::OperationType type, QObject *parent = nullptr)
Constructs an operation runner with operations of type type to be performed, and parent as the parent object.
ConcurrentOperationRunner::ConcurrentOperationRunner(QObject *parent = nullptr)
Constructs an operation runner with parent as the parent object.
[slot]
void ConcurrentOperationRunner::cancel()
Cancels operations pending for an asynchronous run.
Note: This does not stop already running operations, which should provide a separate mechanism for canceling.
[signal]
void ConcurrentOperationRunner::finished()
Emitted when the execution of all pooled operations is finished.
[signal]
void ConcurrentOperationRunner::operationStarted(QInstaller::Operation *operation)
Emitted when the execution of operation is started.
[signal]
void ConcurrentOperationRunner::progressChanged(const int completed, const int total)
Emitted when the count of completed of the total operations changes.
[virtual]
ConcurrentOperationRunner::~ConcurrentOperationRunner()
Destroys the instance and releases resources.
QHash<Operation *, bool> ConcurrentOperationRunner::run()
Performs the current operations. Returns a hash of pointers to the performed operation objects and their results. The result is a boolean value.
void ConcurrentOperationRunner::setMaxThreadCount(int count)
Sets the maximum count of threads used by the thread pool of this class. A value of 0
sets the count automatically to ideal number of threads.
void ConcurrentOperationRunner::setOperations(OperationList *operations)
Sets the list of operations to be performed to operations.
void ConcurrentOperationRunner::setType(const Operation::OperationType type)
Sets type of operations to be performed. This can be either Backup
, Perform
, or Undo
.