BornAgain
1.18.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Public Types | |
typedef std::function< bool(size_t)> | Callback_t |
Public Member Functions | |
ProgressHandler () | |
ProgressHandler (const ProgressHandler &other) | |
void | subscribe (ProgressHandler::Callback_t callback) |
void | reset () |
void | setExpectedNTicks (size_t n) |
void | incrementDone (size_t ticks_done) |
bool | alive () |
Private Member Functions | |
bool | defaultMonitorExec (int) |
Private Attributes | |
Callback_t | m_inform |
size_t | m_expected_nticks |
size_t | m_completed_nticks |
bool | m_continuation_flag |
Maintains information about progress of a computation.
Owner is the computation, which periodically calls the thread-safe function incrementDone(..). An application (GUI or script) may subscribe(..) to be informed about progress. It is then periodically called back by inform(..). The return value of inform(..) can be used to request termination of the computation.
Definition at line 30 of file ProgressHandler.h.
typedef std::function<bool(size_t)> ProgressHandler::Callback_t |
Definition at line 33 of file ProgressHandler.h.
|
inline |
Definition at line 35 of file ProgressHandler.h.
|
inline |
Definition at line 39 of file ProgressHandler.h.
void ProgressHandler::subscribe | ( | ProgressHandler::Callback_t | callback | ) |
Definition at line 19 of file ProgressHandler.cpp.
References m_inform.
Referenced by Simulation::setTerminalProgressMonitor(), and Simulation::subscribe().
|
inline |
Definition at line 46 of file ProgressHandler.h.
References m_completed_nticks, and m_continuation_flag.
Referenced by Simulation::runSimulation().
|
inline |
Definition at line 51 of file ProgressHandler.h.
References m_expected_nticks.
Referenced by Simulation::runSimulation().
void ProgressHandler::incrementDone | ( | size_t | ticks_done | ) |
Increments number of completed computation steps (ticks).
Performs callback (method m_inform) to inform the subscriber about the state of the computation and to obtain as return value a flag that indicates whether to continue the computation.
Definition at line 31 of file ProgressHandler.cpp.
References m_completed_nticks, m_continuation_flag, m_expected_nticks, and m_inform.
Referenced by DelayedProgressCounter::stepProgress().
|
inline |
Definition at line 53 of file ProgressHandler.h.
References m_continuation_flag.
Referenced by DepthProbeComputation::runProtected(), DWBAComputation::runProtected(), and SpecularComputation::runProtected().
|
private |
|
private |
Definition at line 56 of file ProgressHandler.h.
Referenced by incrementDone(), and subscribe().
|
private |
Definition at line 57 of file ProgressHandler.h.
Referenced by incrementDone(), and setExpectedNTicks().
|
private |
Definition at line 58 of file ProgressHandler.h.
Referenced by incrementDone(), and reset().
|
private |
Definition at line 59 of file ProgressHandler.h.
Referenced by alive(), incrementDone(), and reset().