mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
check if update timestamps list is empty after removing all outdated entrys
This commit is contained in:
parent
03f619fac1
commit
ae096e2d2e
@ -67,7 +67,10 @@ void CronManager::runUpdateStep(Poco::Timer& timer)
|
|||||||
|
|
||||||
mTimestampsMutex.lock();
|
mTimestampsMutex.lock();
|
||||||
//printf("update timestamp sizes: %d\n", mUpdateTimestamps.size());
|
//printf("update timestamp sizes: %d\n", mUpdateTimestamps.size());
|
||||||
if (mUpdateTimestamps.size() > 0) {
|
bool timerRestarted = false;
|
||||||
|
|
||||||
|
if (mUpdateTimestamps.size() > 0)
|
||||||
|
{
|
||||||
Poco::Timestamp now;
|
Poco::Timestamp now;
|
||||||
// update maximal once per second
|
// update maximal once per second
|
||||||
now += Poco::Timespan(1, 0);
|
now += Poco::Timespan(1, 0);
|
||||||
@ -75,19 +78,21 @@ void CronManager::runUpdateStep(Poco::Timer& timer)
|
|||||||
// printf("remove update time in past: %d\n", mUpdateTimestamps.front().epochTime());
|
// printf("remove update time in past: %d\n", mUpdateTimestamps.front().epochTime());
|
||||||
mUpdateTimestamps.pop_front();
|
mUpdateTimestamps.pop_front();
|
||||||
}
|
}
|
||||||
Poco::Timespan next_run = mUpdateTimestamps.front() - now;
|
if (mUpdateTimestamps.size() > 0) {
|
||||||
//printf("timer restart called with: %d\n", next_run.seconds());
|
Poco::Timespan next_run = mUpdateTimestamps.front() - now;
|
||||||
//mMainTimer.setPeriodicInterval(next_run.totalMilliseconds());
|
//printf("timer restart called with: %d\n", next_run.seconds());
|
||||||
mMainTimer.restart(next_run.totalMilliseconds());
|
//mMainTimer.setPeriodicInterval(next_run.totalMilliseconds());
|
||||||
mUpdateTimestamps.pop_front();
|
mMainTimer.restart(next_run.totalMilliseconds());
|
||||||
}
|
mUpdateTimestamps.pop_front();
|
||||||
else {
|
timerRestarted = true;
|
||||||
if (mMainTimer.getPeriodicInterval() != mDefaultIntervalMilliseconds) {
|
|
||||||
//printf("reset to default interval\n");
|
|
||||||
mMainTimer.setPeriodicInterval(mDefaultIntervalMilliseconds);
|
|
||||||
//mMainTimer.restart(mDefaultIntervalMilliseconds);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!timerRestarted && mMainTimer.getPeriodicInterval() != mDefaultIntervalMilliseconds) {
|
||||||
|
//printf("reset to default interval\n");
|
||||||
|
mMainTimer.setPeriodicInterval(mDefaultIntervalMilliseconds);
|
||||||
|
//mMainTimer.restart(mDefaultIntervalMilliseconds);
|
||||||
|
}
|
||||||
mTimestampsMutex.unlock();
|
mTimestampsMutex.unlock();
|
||||||
//printf("[CronManager::runUpdateStep] end\n");
|
//printf("[CronManager::runUpdateStep] end\n");
|
||||||
}
|
}
|
||||||
@ -188,8 +193,8 @@ int PingServerTask::run()
|
|||||||
std::string url_port = mNodeServer->getModel()->getUrlWithPort();
|
std::string url_port = mNodeServer->getModel()->getUrlWithPort();
|
||||||
printf("%s [PingServerTask::run] call update for %s\n", Poco::DateTimeFormatter::format(current, "%d.%m.%y %H:%M:%S.%i").data(), url_port.data());
|
printf("%s [PingServerTask::run] call update for %s\n", Poco::DateTimeFormatter::format(current, "%d.%m.%y %H:%M:%S.%i").data(), url_port.data());
|
||||||
|
|
||||||
auto json_request = mNodeServer->createJsonRequest();
|
//auto json_request = mNodeServer->createJsonRequest();
|
||||||
json_request.request("updateReadNode");
|
//json_request.request("updateReadNode");
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user