BornAgain
1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
|
Maintains information about progress of a computation. More...
Public Types | |
typedef std::function< bool(size_t)> | Callback_t |
Public Member Functions | |
ProgressHandler () | |
ProgressHandler (const ProgressHandler &other) | |
bool | alive () |
void | incrementDone (size_t ticks_done) |
Increments number of completed computation steps (ticks). More... | |
void | reset () |
void | setExpectedNTicks (size_t n) |
void | subscribe (ProgressHandler::Callback_t callback) |
Private Member Functions | |
bool | defaultMonitorExec (int) |
Private Attributes | |
size_t | m_completed_nticks |
bool | m_continuation_flag |
size_t | m_expected_nticks |
Callback_t | m_inform |
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 35 of file ProgressHandler.h.
typedef std::function<bool(size_t)> ProgressHandler::Callback_t |
Definition at line 37 of file ProgressHandler.h.
|
inline |
Definition at line 39 of file ProgressHandler.h.
|
inline |
Definition at line 43 of file ProgressHandler.h.
|
inline |
Definition at line 57 of file ProgressHandler.h.
References m_continuation_flag.
Referenced by DepthProbeComputation::runProtected(), DWBAComputation::runProtected(), and SpecularComputation::runProtected().
|
private |
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 50 of file ProgressHandler.h.
References m_completed_nticks, and m_continuation_flag.
Referenced by ISimulation::runSimulation().
|
inline |
Definition at line 55 of file ProgressHandler.h.
References m_expected_nticks.
Referenced by ISimulation::runSimulation().
void ProgressHandler::subscribe | ( | ProgressHandler::Callback_t | callback | ) |
Definition at line 19 of file ProgressHandler.cpp.
References m_inform.
Referenced by ISimulation::setTerminalProgressMonitor(), and ISimulation::subscribe().
|
private |
Definition at line 62 of file ProgressHandler.h.
Referenced by incrementDone(), and reset().
|
private |
Definition at line 63 of file ProgressHandler.h.
Referenced by alive(), incrementDone(), and reset().
|
private |
Definition at line 61 of file ProgressHandler.h.
Referenced by incrementDone(), and setExpectedNTicks().
|
private |
Definition at line 60 of file ProgressHandler.h.
Referenced by incrementDone(), and subscribe().