BornAgain
1.19.79
Open-source research software to simulate and fit neutron and x-ray reflectometry and grazing-incidence small-angle scattering
|
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 34 of file ProgressHandler.h.
Public Types | |
using | Callback_t = std::function< bool(size_t)> |
Public Member Functions | |
ProgressHandler () | |
ProgressHandler (const ProgressHandler &other) | |
bool | alive () |
void | 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. More... | |
void | reset () |
void | setExpectedNTicks (size_t n) |
void | subscribe (ProgressHandler::Callback_t inform) |
Private Member Functions | |
bool | defaultMonitorExec (int) |
Private Attributes | |
size_t | m_completed_nticks {0} |
bool | m_continuation_flag {true} |
size_t | m_expected_nticks {0} |
Callback_t | m_inform |
using ProgressHandler::Callback_t = std::function<bool(size_t)> |
Definition at line 36 of file ProgressHandler.h.
|
inline |
Definition at line 38 of file ProgressHandler.h.
|
inline |
Definition at line 42 of file ProgressHandler.h.
|
inline |
Definition at line 56 of file ProgressHandler.h.
References m_continuation_flag.
Referenced by IComputation::compute(), and DWBAComputation::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 49 of file ProgressHandler.h.
References m_completed_nticks, and m_continuation_flag.
|
inline |
void ProgressHandler::subscribe | ( | ProgressHandler::Callback_t | inform | ) |
|
private |
Definition at line 61 of file ProgressHandler.h.
Referenced by incrementDone(), and reset().
|
private |
Definition at line 62 of file ProgressHandler.h.
Referenced by alive(), incrementDone(), and reset().
|
private |
Definition at line 60 of file ProgressHandler.h.
Referenced by incrementDone(), and setExpectedNTicks().
|
private |
Definition at line 59 of file ProgressHandler.h.
Referenced by incrementDone(), and subscribe().