summaryrefslogtreecommitdiff
path: root/src/ServerStatMan.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-06-09 03:04:38 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2015-06-09 03:15:10 +0900
commitb0f440e631efe18099ced96b604447b5fdce28d8 (patch)
treed4a705616a58c314eab568772d5a3c4cc53bd69b /src/ServerStatMan.cc
parent99cd73c0926f0c07d27777fde2f15816e8040030 (diff)
Rewrite Time with chrono
Diffstat (limited to 'src/ServerStatMan.cc')
-rw-r--r--src/ServerStatMan.cc23
1 files changed, 4 insertions, 19 deletions
diff --git a/src/ServerStatMan.cc b/src/ServerStatMan.cc
index 4c2e46f2..ad8e4e41 100644
--- a/src/ServerStatMan.cc
+++ b/src/ServerStatMan.cc
@@ -233,26 +233,11 @@ bool ServerStatMan::load(const std::string& filename)
return true;
}
-namespace {
-class FindStaleServerStat {
-private:
- time_t timeout_;
- Time time_;
-public:
- FindStaleServerStat(time_t timeout):timeout_(timeout) {}
-
- bool operator()(const std::shared_ptr<ServerStat>& ss) const
- {
- return ss->getLastUpdated().difference(time_) >= timeout_;
- }
-};
-} // namespace
-
-void ServerStatMan::removeStaleServerStat(time_t timeout)
+void ServerStatMan::removeStaleServerStat(const std::chrono::seconds& timeout)
{
- FindStaleServerStat finder(timeout);
- for(auto i = serverStats_.begin(), eoi = serverStats_.end(); i != eoi;) {
- if(finder(*i)) {
+ auto now = Time();
+ for(auto i = std::begin(serverStats_); i != std::end(serverStats_);) {
+ if((*i)->getLastUpdated().difference(now) >= timeout) {
serverStats_.erase(i++);
} else {
++i;