8#ifndef MODEL_RUN_STATE_H
9#define MODEL_RUN_STATE_H
14#include <forward_list>
51 recursive_mutex theMutex;
66 tuple<bool, RunState>
get(
int i_runId,
int i_subId);
72 void add(
int i_runId,
int i_subId,
RunState i_state);
78 bool updateProgress(
int i_runId,
int i_subId,
int i_count,
double i_value);
92 recursive_mutex theMutex;
93 map<pair<int, int>,
RunState> stateMap;
94 map<pair<int, int>,
RunState> updateStateMap;
95 chrono::system_clock::time_point lastSaveTime = chrono::system_clock::time_point::min();
model run state: thread safe
Definition: modelRunState.h:24
RunState get(void) override
return model run state data
Definition: modelRunState.cpp:134
ModelStatus status(void) override
get model status
Definition: modelRunState.cpp:106
bool isError(void) override
return true if status is an error
Definition: modelRunState.cpp:120
ModelRunState(void)
initialize model run state
Definition: modelRunState.h:27
ModelStatus updateStatus(ModelStatus i_status) override
set model status if not already set as one of final status values
Definition: modelRunState.cpp:141
bool isShutdownOrFinal(void) override
return true if model in shutdown state: modeling completed or one of exiting
Definition: modelRunState.cpp:127
void updateProgress(int i_count, double i_value=0.0) override
set modeling progress count and value
Definition: modelRunState.cpp:149
bool isFinal(void) override
return true if status is one of exiting: ie done, exit, error
Definition: modelRunState.cpp:113
sub-value run state for all modeling threads, identified by (run id, sub-value id) pair
Definition: modelRunState.h:61
tuple< bool, RunState > get(int i_runId, int i_subId)
find sub-value run state, return false and empty sub-value run state if not exist
Definition: modelRunState.cpp:156
ModelStatus updateStatus(int i_runId, int i_subId, ModelStatus i_status, bool i_isFinalUpdate=true)
update sub-value status if not already set as one of final status values, return actual status or und...
Definition: modelRunState.cpp:174
bool updateProgress(int i_runId, int i_subId, int i_count, double i_value)
set modeling progress count and value, return false if not exist
Definition: modelRunState.cpp:192
void add(int i_runId, int i_subId)
add new or replace existing sub-value run state
Definition: modelRunState.h:69
const map< pair< int, int >, RunState > saveUpdated(bool i_isNow=false)
return updated sub-values run state since previous call.
Definition: modelRunState.cpp:207
IRowBaseVec saveToRowVector(int i_runId)
copy updated run states into output vector of (run id, sub-value id, run state), last element is proc...
Definition: modelRunState.cpp:231
const RunState fromRowVector(const IRowBaseVec &i_src)
append or replace existing run states from received vector of (run id, sub-value id,...
Definition: modelRunState.cpp:253
OpenM++ common helper utilities.
openM++ namespace
Definition: log.h:32
ModelStatus
modeling job status
Definition: omModelRunState.h:43
std::vector< IRowBaseUptr > IRowBaseVec
db rows: vector of unique pointers to db row
Definition: omHelper.h:239
OpenM++ modeling library: public interface.
model run state public interface: thread safe
Definition: omModelRunState.h:139
model run state data: status, progress, update times
Definition: omModelRunState.h:93