a method called lastCall is called for everything contained in that checkpoint
(stats, updaters and monitors). This can be extremely useful
- for stateSavers (see below)
- for monitoring things like rates of success of operators, where what you
are interested in is the final result only.
Added of course a virtual method lastCall that does nothing by default in classes
eoBaseStat, eoBaseSortedStat, eoUpdater and eoMonitor
Added a boolean to control the save of the state in method eoCountedStateSaver::lastCall
so you can ask that the state is saved at final population, whatever happens.
I also added the corresponding constructor to take this into account.
46 lines
758 B
C++
46 lines
758 B
C++
#ifdef _MSC_VER
|
|
#pragma warning(disable:4786)
|
|
#endif
|
|
|
|
|
|
#include <strstream>
|
|
|
|
#include <utils/eoState.h>
|
|
#include <utils/eoUpdater.h>
|
|
|
|
using namespace std;
|
|
|
|
void eoTimedStateSaver::operator()(void)
|
|
{
|
|
time_t now = time(0);
|
|
|
|
if (now >= last_time + interval)
|
|
{
|
|
last_time = now;
|
|
|
|
ostrstream os;
|
|
os << prefix << (now - first_time) << '.' << extension << ends;
|
|
state.save(os.str());
|
|
}
|
|
}
|
|
|
|
void eoCountedStateSaver::doItNow(void)
|
|
{
|
|
ostrstream os;
|
|
os << prefix << counter << '.' << extension << ends;
|
|
state.save(os.str());
|
|
}
|
|
|
|
void eoCountedStateSaver::operator()(void)
|
|
{
|
|
if (++counter % interval == 0)
|
|
doItNow();
|
|
}
|
|
|
|
void eoCountedStateSaver::lastCall(void)
|
|
{
|
|
if (saveOnLastCall)
|
|
doItNow();
|
|
}
|
|
|
|
|