, _thread (0)
, _state (NEW)
, _start_time (0)
+ , _sub_start_time (0)
, _progress (0)
, _ran_for (0)
{
{
set_state (RUNNING);
_start_time = time (0);
+ _sub_start_time = time (0);
_thread = new boost::thread (boost::bind (&Job::run_wrapper, this));
}
_state = s;
if (_state == FINISHED_OK || _state == FINISHED_ERROR || _state == FINISHED_CANCELLED) {
- _ran_for = elapsed_time ();
+ _ran_for = time(0) - _start_time;
finished = true;
_sub_name.clear ();
}
/** @return DCPTime (in seconds) that this sub-job has been running */
int
-Job::elapsed_time () const
+Job::elapsed_sub_time () const
{
- if (_start_time == 0) {
+ if (_sub_start_time == 0) {
return 0;
}
- return time (0) - _start_time;
+ return time (0) - _sub_start_time;
}
/** Set the progress of the current part of the job.
}
set_progress (0, true);
+ _sub_start_time = time (0);
}
string
Job::status () const
{
optional<float> p = progress ();
- int const t = elapsed_time ();
+ int const t = elapsed_sub_time ();
int const r = remaining_time ();
- SafeStringStream s;
+ locked_stringstream s;
if (!finished () && p) {
int pc = lrintf (p.get() * 100);
if (pc == 100) {
Job::remaining_time () const
{
if (progress().get_value_or(0) == 0) {
- return elapsed_time ();
+ return elapsed_sub_time ();
}
- return elapsed_time() / progress().get() - elapsed_time();
+ return elapsed_sub_time() / progress().get() - elapsed_sub_time();
}
void