BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
jobmanager.h
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // BornAgain: simulate and fit reflection and scattering
4 //
5 //! @file gui2/quicksimeditor/jobmanager.h
6 //! @brief Defines class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
15 #ifndef BORNAGAIN_GUI2_QUICKSIMEDITOR_JOBMANAGER_H
16 #define BORNAGAIN_GUI2_QUICKSIMEDITOR_JOBMANAGER_H
17 
18 #include "darefl_export.h"
21 #include <QObject>
22 
23 namespace gui2 {
24 
25 //! Handles all thread activity for running job simulation in the background.
26 
27 class DAREFLCORE_EXPORT JobManager : public QObject {
28  Q_OBJECT
29 
30 public:
31  JobManager(QObject* parent = nullptr);
32  ~JobManager() override;
33 
34  SimulationResult simulationResult();
35 
36 signals:
37  void progressChanged(int value);
39 
40 public slots:
41  void requestSimulation(const multislice_t& multislice, const std::vector<double>& qvalues,
42  double intensity);
43  void onInterruptRequest();
44 
45 private:
46  void wait_and_run();
47 
48  std::thread m_simThread;
51  std::atomic<bool> m_isRunning;
52  bool m_interruptRequest{false};
53 };
54 
55 } // namespace gui2
56 
57 #endif // BORNAGAIN_GUI2_QUICKSIMEDITOR_JOBMANAGER_H
Thread-safe stack borrowed from Anthony Williams, C++ Concurrency in Action, Second edition.
Handles all thread activity for running job simulation in the background.
Definition: jobmanager.h:27
std::atomic< bool > m_isRunning
Definition: jobmanager.h:51
ModelView::threadsafe_stack< SimulationInput > m_requestedInputValues
Definition: jobmanager.h:49
void simulationCompleted()
ModelView::threadsafe_stack< SimulationResult > m_simulationResult
Definition: jobmanager.h:50
void progressChanged(int value)
std::thread m_simThread
Definition: jobmanager.h:48
Based on Qt example "codeeditor" Copyright (C) 2016 The Qt Company Ltd.
Definition: app_constants.h:20
std::vector< SliceData > multislice_t
Defines class CLASS?
Represents results of the simulation.
Defines class CLASS?