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. More... | |
Public Member Functions | |
void | addAlgorithm (const Mantid::API::IAlgorithm_sptr &algo) |
Adds an algorithm to the execution queue. More... | |
void | addAlgorithm (const Mantid::API::IAlgorithm_sptr &algo, std::unique_ptr< IAlgorithmRuntimeProps > props) |
Adds an algorithm to the end of the queue. More... | |
BatchAlgorithmRunner (QObject *parent=nullptr) | |
void | cancelBatch () |
Request to cancel processing the batch. More... | |
void | clearQueue () |
Clears all algorithms from queue. More... | |
bool | executeBatch () |
Executes the batch, waits for the result and returns it. More... | |
void | executeBatchAsync () |
Starts the batch executing and returns immediately. More... | |
size_t | queueLength () |
Gets size of queue. More... | |
void | setQueue (std::deque< IConfiguredAlgorithm_sptr > algorithm) |
Set the queue of algorithms. More... | |
void | stopOnFailure (bool stopOnFailure) |
Sets if the execuion should be stopped if an error is detected. More... | |
~BatchAlgorithmRunner () override | |
Private Member Functions | |
void | addAllObservers () |
bool | cancelRequested () |
bool | executeAlgo (const IConfiguredAlgorithm_sptr &algorithm) |
Sets up and executes an algorithm. More... | |
Poco::ActiveResult< bool > | executeAsync () |
Holds result of async execution. More... | |
bool | executeBatchAsyncImpl (const Poco::Void &) |
Implementation of algorithm runner. More... | |
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. More... | |
void | removeAllObservers () |
void | resetState () |
Reset state ready for executing a new batch. More... | |
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 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 89 of file BatchAlgorithmRunner.cpp.
References addAlgorithm().
Referenced by addAlgorithm().
void MantidQt::API::BatchAlgorithmRunner::addAlgorithm | ( | const Mantid::API::IAlgorithm_sptr & | algo, |
std::unique_ptr< 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 100 of file BatchAlgorithmRunner.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, and m_algorithms.
|
private |
Definition at line 59 of file BatchAlgorithmRunner.cpp.
References m_algorithmCompleteObserver, m_algorithmErrorObserver, m_algorithmStartedObserver, m_batchCancelledObserver, m_batchCompleteObserver, and m_notificationCenter.
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 153 of file BatchAlgorithmRunner.cpp.
References addAllObservers(), m_cancelRequested, m_mutex, m_notificationCenter, queueLength(), and removeAllObservers().
|
private |
Definition at line 177 of file BatchAlgorithmRunner.cpp.
References m_cancelRequested, and m_mutex.
Referenced by executeBatchAsyncImpl().
void MantidQt::API::BatchAlgorithmRunner::clearQueue | ( | ) |
Clears all algorithms from queue.
Removes all algorithms from the queue.
Definition at line 122 of file BatchAlgorithmRunner.cpp.
References m_algorithms.
Referenced by 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 226 of file BatchAlgorithmRunner.cpp.
References Mantid::API::g_log, Mantid::Kernel::Logger::information(), m_currentAlgorithm, m_notificationCenter, UNUSED_ARG, Mantid::Kernel::Logger::warning(), and Mantid::Kernel::Exception::NotFoundError::what().
Referenced by executeBatchAsyncImpl().
|
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 134 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 145 of file BatchAlgorithmRunner.cpp.
References addAllObservers(), and m_executeAsync.
|
private |
Implementation of algorithm runner.
Implementation of sequential algorithm scheduler.
Definition at line 185 of file BatchAlgorithmRunner.cpp.
References cancelRequested(), executeAlgo(), Mantid::API::g_log, Mantid::Kernel::Logger::information(), m_algorithms, m_currentAlgorithm, m_notificationCenter, m_stopOnFailure, resetState(), and Mantid::Kernel::Logger::warning().
|
private |
Definition at line 302 of file BatchAlgorithmRunner.cpp.
References algorithmComplete().
|
private |
Definition at line 307 of file BatchAlgorithmRunner.cpp.
References algorithmError().
|
private |
Definition at line 297 of file BatchAlgorithmRunner.cpp.
References algorithmStarted().
|
private |
Definition at line 291 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 283 of file BatchAlgorithmRunner.cpp.
References batchComplete().
size_t MantidQt::API::BatchAlgorithmRunner::queueLength | ( | ) |
Gets size of queue.
Returns the number of algorithms in the queue.
Definition at line 127 of file BatchAlgorithmRunner.cpp.
References m_algorithms.
Referenced by cancelBatch().
|
private |
Definition at line 67 of file BatchAlgorithmRunner.cpp.
References m_algorithmCompleteObserver, m_algorithmErrorObserver, m_algorithmStartedObserver, m_batchCancelledObserver, m_batchCompleteObserver, and m_notificationCenter.
Referenced by cancelBatch(), executeBatch(), resetState(), and ~BatchAlgorithmRunner().
|
private |
Reset state ready for executing a new batch.
Definition at line 170 of file BatchAlgorithmRunner.cpp.
References clearQueue(), m_cancelRequested, m_mutex, and removeAllObservers().
Referenced by executeBatchAsyncImpl().
void MantidQt::API::BatchAlgorithmRunner::setQueue | ( | std::deque< IConfiguredAlgorithm_sptr > | algorithms | ) |
Set the queue of algorithms.
algorithms | The queue of configured algorithms |
Definition at line 111 of file BatchAlgorithmRunner.cpp.
References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, and m_algorithms.
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 82 of file BatchAlgorithmRunner.cpp.
References m_stopOnFailure, and stopOnFailure().
Referenced by stopOnFailure().
|
private |
Definition at line 155 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), and removeAllObservers().
|
private |
Definition at line 156 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), and removeAllObservers().
|
private |
The queue of algorithms to be executed.
Definition at line 135 of file BatchAlgorithmRunner.h.
Referenced by addAlgorithm(), clearQueue(), executeBatchAsyncImpl(), queueLength(), and setQueue().
|
private |
Definition at line 154 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), and removeAllObservers().
|
private |
Definition at line 153 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), and removeAllObservers().
|
private |
Observer for notifications.
Definition at line 152 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), and removeAllObservers().
|
private |
User has requested to cancel processing.
Definition at line 144 of file BatchAlgorithmRunner.h.
Referenced by cancelBatch(), cancelRequested(), and resetState().
|
private |
The current algorithm being executed.
Definition at line 138 of file BatchAlgorithmRunner.h.
Referenced by executeAlgo(), and executeBatchAsyncImpl().
|
private |
Active method to run batch runner on separate thread.
Definition at line 159 of file BatchAlgorithmRunner.h.
Referenced by executeBatch(), and executeBatchAsync().
|
private |
Definition at line 145 of file BatchAlgorithmRunner.h.
Referenced by cancelBatch(), cancelRequested(), and resetState().
|
mutableprivate |
Notification center used to handle notifications from active method.
Definition at line 150 of file BatchAlgorithmRunner.h.
Referenced by addAllObservers(), cancelBatch(), executeAlgo(), executeBatchAsyncImpl(), and removeAllObservers().
|
private |
If execution should be stopped on algorithm failure.
Definition at line 141 of file BatchAlgorithmRunner.h.
Referenced by executeBatchAsyncImpl(), and stopOnFailure().