|
Mantid
|
Algorithm runner for execution of a queue of algorithms. More...
#include <BatchAlgorithmRunner.h>
Signals | |
| void | algorithmComplete (MantidQt::API::IConfiguredAlgorithm_sptr algorithm) |
| void | algorithmError (MantidQt::API::IConfiguredAlgorithm_sptr algorithm, std::string errorMessage) |
| void | algorithmStarted (MantidQt::API::IConfiguredAlgorithm_sptr algorithm) |
| void | batchCancelled () |
| void | batchComplete (bool error) |
| Emitted when a batch has finished executing. | |
Public Member Functions | |
| void | addAlgorithm (const Mantid::API::IAlgorithm_sptr &algo) |
| Adds an algorithm to the execution queue. | |
| void | addAlgorithm (const Mantid::API::IAlgorithm_sptr &algo, std::unique_ptr< Mantid::API::IAlgorithmRuntimeProps > props) |
| Adds an algorithm to the end of the queue. | |
| BatchAlgorithmRunner (QObject *parent=nullptr) | |
| void | cancelBatch () |
| Request to cancel processing the batch. | |
| void | clearQueue () |
| Clears all algorithms from queue. | |
| void | executeAlgorithmAsync (IConfiguredAlgorithm_sptr algorithm) |
| Starts a single algorithm and returns immediately. | |
| bool | executeBatch () |
| Executes the batch, waits for the result and returns it. | |
| void | executeBatchAsync () |
| Starts the batch executing and returns immediately. | |
| size_t | queueLength () |
| Gets size of queue. | |
| void | setQueue (std::deque< IConfiguredAlgorithm_sptr > algorithm) |
| Set the queue of algorithms. | |
| void | stopOnFailure (bool stopOnFailure) |
| Sets if the execuion should be stopped if an error is detected. | |
| ~BatchAlgorithmRunner () override | |
Private Member Functions | |
| void | addAllObservers () |
| bool | cancelRequested () |
| bool | executeAlgo (const IConfiguredAlgorithm_sptr &algorithm) |
| Sets up and executes an algorithm. | |
| Poco::ActiveResult< bool > | executeAsync () |
| Holds result of async execution. | |
| bool | executeBatchAsyncImpl (const Poco::Void &) |
| Implementation of algorithm runner. | |
| void | handleAlgorithmComplete (const Poco::AutoPtr< AlgorithmCompleteNotification > &pNf) |
| void | handleAlgorithmError (const Poco::AutoPtr< AlgorithmErrorNotification > &pNf) |
| void | handleAlgorithmStarted (const Poco::AutoPtr< AlgorithmStartedNotification > &pNf) |
| void | handleBatchCancelled (const Poco::AutoPtr< BatchCancelledNotification > &pNf) |
| void | handleBatchComplete (const Poco::AutoPtr< BatchCompleteNotification > &pNf) |
| Handlers for notifications. | |
| void | postNotification (Poco::Notification *notification) |
| Post a poco notification. | |
| void | removeAllObservers () |
| void | resetState () |
| Reset state ready for executing a new batch. | |
| void | setCancelRequested (bool const cancel) |
Algorithm runner for execution of a queue of algorithms.
Definition at line 86 of file BatchAlgorithmRunner.h.
|
explicit |
Definition at line 48 of file BatchAlgorithmRunner.cpp.
|
override |
Definition at line 57 of file BatchAlgorithmRunner.cpp.
References m_executeAsync, and removeAllObservers().
| void MantidQt::API::BatchAlgorithmRunner::addAlgorithm | ( | const Mantid::API::IAlgorithm_sptr & | algo | ) |
Adds an algorithm to the execution queue.
Adds an algorithm to the end of the queue with blank properties.
| algo | Algorithm to add to queue |
Definition at line 96 of file BatchAlgorithmRunner.cpp.
References addAlgorithm().
Referenced by addAlgorithm().
| void MantidQt::API::BatchAlgorithmRunner::addAlgorithm | ( | const Mantid::API::IAlgorithm_sptr & | algo, |
| std::unique_ptr< Mantid::API::IAlgorithmRuntimeProps > | props | ||
| ) |
Adds an algorithm to the end of the queue.
| algo | Algorithm to add to queue |
| props | Optional map of property name to property values to be set just before execution (mainly intended for input and inout workspace names) |
Definition at line 107 of file BatchAlgorithmRunner.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, and m_algorithms.
|
private |
Definition at line 64 of file BatchAlgorithmRunner.cpp.
References m_algorithmCompleteObserver, m_algorithmErrorObserver, m_algorithmStartedObserver, m_batchCancelledObserver, m_batchCompleteObserver, m_notificationCenter, and m_notificationMutex.
Referenced by cancelBatch(), executeBatch(), and executeBatchAsync().
|
signal |
Referenced by handleAlgorithmComplete().
|
signal |
Referenced by handleAlgorithmError().
|
signal |
Referenced by handleAlgorithmStarted().
|
signal |
Referenced by handleBatchCancelled().
|
signal |
Emitted when a batch has finished executing.
Referenced by handleBatchComplete().
| void MantidQt::API::BatchAlgorithmRunner::cancelBatch | ( | ) |
Request to cancel processing the batch.
Cancel execution of remaining queued items.
Definition at line 179 of file BatchAlgorithmRunner.cpp.
References addAllObservers(), m_executeMutex, postNotification(), removeAllObservers(), and setCancelRequested().
Referenced by MantidQt::API::QtJobRunner::cancelAlgorithmQueue().
|
private |
Definition at line 202 of file BatchAlgorithmRunner.cpp.
References m_cancelMutex, and m_cancelRequested.
Referenced by executeBatchAsyncImpl().
| void MantidQt::API::BatchAlgorithmRunner::clearQueue | ( | ) |
Clears all algorithms from queue.
Removes all algorithms from the queue.
Definition at line 130 of file BatchAlgorithmRunner.cpp.
References m_algorithms, and m_executeMutex.
Referenced by MantidQt::API::QtJobRunner::clearAlgorithmQueue(), and resetState().
|
private |
Sets up and executes an algorithm.
Assigns properties to an algorithm then executes it.
| algorithm | Algorithm and properties to assign to it |
Definition at line 252 of file BatchAlgorithmRunner.cpp.
References Mantid::API::g_log, Mantid::Kernel::Logger::information(), m_currentAlgorithm, postNotification(), UNUSED_ARG, Mantid::Kernel::Logger::warning(), and Mantid::Kernel::Exception::NotFoundError::what().
Referenced by executeBatchAsyncImpl().
| void MantidQt::API::BatchAlgorithmRunner::executeAlgorithmAsync | ( | IConfiguredAlgorithm_sptr | algorithm | ) |
Starts a single algorithm and returns immediately.
Starts the execution of a single algorithm on a separate thread.
| algorithm | The algorithm to execute asynchronously |
Definition at line 169 of file BatchAlgorithmRunner.cpp.
References executeBatchAsync(), and setQueue().
Referenced by MantidQt::API::QtJobRunner::executeAlgorithm().
|
private |
Holds result of async execution.
| bool MantidQt::API::BatchAlgorithmRunner::executeBatch | ( | ) |
Executes the batch, waits for the result and returns it.
Executes the algorithms on a separate thread and waits for their completion.
Definition at line 148 of file BatchAlgorithmRunner.cpp.
References addAllObservers(), m_executeAsync, and removeAllObservers().
| void MantidQt::API::BatchAlgorithmRunner::executeBatchAsync | ( | ) |
Starts the batch executing and returns immediately.
Starts executing the queue of algorithms on a separate thread.
Definition at line 159 of file BatchAlgorithmRunner.cpp.
References addAllObservers(), and m_executeAsync.
Referenced by executeAlgorithmAsync(), and MantidQt::API::QtJobRunner::executeAlgorithmQueue().
|
private |
Implementation of algorithm runner.
Implementation of sequential algorithm scheduler.
Definition at line 210 of file BatchAlgorithmRunner.cpp.
References cancelRequested(), executeAlgo(), Mantid::API::g_log, Mantid::Kernel::Logger::information(), m_algorithms, m_currentAlgorithm, m_executeMutex, m_stopOnFailure, postNotification(), resetState(), and Mantid::Kernel::Logger::warning().
|
private |
Definition at line 339 of file BatchAlgorithmRunner.cpp.
References algorithmComplete().
|
private |
Definition at line 344 of file BatchAlgorithmRunner.cpp.
References algorithmError().
|
private |
Definition at line 334 of file BatchAlgorithmRunner.cpp.
References algorithmStarted().
|
private |
Definition at line 328 of file BatchAlgorithmRunner.cpp.
References batchCancelled(), and UNUSED_ARG.
|
private |
Handlers for notifications.
Handles the notification posted when the algorithm queue stops execution.
| pNf | Notification object |
Definition at line 320 of file BatchAlgorithmRunner.cpp.
References batchComplete().
|
private |
Post a poco notification.
Definition at line 305 of file BatchAlgorithmRunner.cpp.
References m_notificationCenter, and m_notificationMutex.
Referenced by cancelBatch(), executeAlgo(), and executeBatchAsyncImpl().
| size_t MantidQt::API::BatchAlgorithmRunner::queueLength | ( | ) |
Gets size of queue.
Returns the number of algorithms in the queue.
Definition at line 138 of file BatchAlgorithmRunner.cpp.
References m_algorithms, and m_executeMutex.
|
private |
Definition at line 73 of file BatchAlgorithmRunner.cpp.
References m_algorithmCompleteObserver, m_algorithmErrorObserver, m_algorithmStartedObserver, m_batchCancelledObserver, m_batchCompleteObserver, m_notificationCenter, and m_notificationMutex.
Referenced by cancelBatch(), executeBatch(), resetState(), and ~BatchAlgorithmRunner().
|
private |
Reset state ready for executing a new batch.
Definition at line 196 of file BatchAlgorithmRunner.cpp.
References clearQueue(), removeAllObservers(), and setCancelRequested().
Referenced by executeBatchAsyncImpl().
|
private |
Definition at line 310 of file BatchAlgorithmRunner.cpp.
References m_cancelMutex, and m_cancelRequested.
Referenced by cancelBatch(), and resetState().
| void MantidQt::API::BatchAlgorithmRunner::setQueue | ( | std::deque< IConfiguredAlgorithm_sptr > | algorithms | ) |
Set the queue of algorithms.
| algorithms | The queue of configured algorithms |
Definition at line 118 of file BatchAlgorithmRunner.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, m_algorithms, and m_executeMutex.
Referenced by executeAlgorithmAsync(), and MantidQt::API::QtJobRunner::setAlgorithmQueue().
| void MantidQt::API::BatchAlgorithmRunner::stopOnFailure | ( | bool | stopOnFailure | ) |
Sets if the execuion should be stopped if an error is detected.
Sets if the execution of the queue should be stopped if an algorithm fails.
Defaults to true
| stopOnFailure | Flase to continue to tnd of queue on failure |
Definition at line 89 of file BatchAlgorithmRunner.cpp.
References m_stopOnFailure, and stopOnFailure().
Referenced by MantidQt::API::QtJobRunner::QtJobRunner(), and stopOnFailure().
|
private |
Definition at line 164 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), and removeAllObservers().
|
private |
Definition at line 165 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), and removeAllObservers().
|
private |
The queue of algorithms to be executed.
Definition at line 142 of file BatchAlgorithmRunner.h.
Referenced by addAlgorithm(), clearQueue(), executeBatchAsyncImpl(), queueLength(), and setQueue().
|
private |
Definition at line 163 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), and removeAllObservers().
|
private |
Definition at line 162 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), and removeAllObservers().
|
private |
Observer for notifications.
Definition at line 161 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), and removeAllObservers().
|
private |
Definition at line 153 of file BatchAlgorithmRunner.h.
Referenced by cancelRequested(), and setCancelRequested().
|
private |
User has requested to cancel processing.
Definition at line 151 of file BatchAlgorithmRunner.h.
Referenced by cancelRequested(), and setCancelRequested().
|
private |
The current algorithm being executed.
Definition at line 145 of file BatchAlgorithmRunner.h.
Referenced by executeAlgo(), and executeBatchAsyncImpl().
|
private |
Active method to run batch runner on separate thread.
Definition at line 168 of file BatchAlgorithmRunner.h.
Referenced by executeBatch(), executeBatchAsync(), and ~BatchAlgorithmRunner().
|
private |
Definition at line 152 of file BatchAlgorithmRunner.h.
Referenced by cancelBatch(), clearQueue(), executeBatchAsyncImpl(), queueLength(), and setQueue().
|
mutableprivate |
Notification center used to handle notifications from active method.
Definition at line 159 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), postNotification(), and removeAllObservers().
|
private |
Definition at line 154 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), postNotification(), and removeAllObservers().
|
private |
If execution should be stopped on algorithm failure.
Definition at line 148 of file BatchAlgorithmRunner.h.
Referenced by executeBatchAsyncImpl(), and stopOnFailure().