From 07d270c87e6f9184aea4ca17eb26e466712e8db2 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sat, 22 Jun 2013 01:10:38 +0900 Subject: Require -std=c++11 and use std::shared_ptr instead of SharedHandle --- src/ServerStatMan.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/ServerStatMan.cc') diff --git a/src/ServerStatMan.cc b/src/ServerStatMan.cc index 81ae7db5..ddeca299 100644 --- a/src/ServerStatMan.cc +++ b/src/ServerStatMan.cc @@ -56,19 +56,19 @@ ServerStatMan::ServerStatMan() {} ServerStatMan::~ServerStatMan() {} -SharedHandle ServerStatMan::find(const std::string& hostname, +std::shared_ptr ServerStatMan::find(const std::string& hostname, const std::string& protocol) const { - SharedHandle ss(new ServerStat(hostname, protocol)); + std::shared_ptr ss(new ServerStat(hostname, protocol)); ServerStatSet::iterator i = serverStats_.find(ss); if(i == serverStats_.end()) { - return SharedHandle(); + return std::shared_ptr(); } else { return *i; } } -bool ServerStatMan::add(const SharedHandle& serverStat) +bool ServerStatMan::add(const std::shared_ptr& serverStat) { ServerStatSet::iterator i = serverStats_.lower_bound(serverStat); if(i != serverStats_.end() && *(*i) == *serverStat) { @@ -195,7 +195,7 @@ bool ServerStatMan::load(const std::string& filename) if(m[S_HOST].empty() || m[S_PROTOCOL].empty()) { continue; } - SharedHandle sstat(new ServerStat(m[S_HOST], m[S_PROTOCOL])); + std::shared_ptr sstat(new ServerStat(m[S_HOST], m[S_PROTOCOL])); uint32_t uintval; if(!util::parseUIntNoThrow(uintval, m[S_DL_SPEED])) { @@ -243,7 +243,7 @@ private: public: FindStaleServerStat(time_t timeout):timeout_(timeout) {} - bool operator()(const SharedHandle& ss) const + bool operator()(const std::shared_ptr& ss) const { return ss->getLastUpdated().difference(time_) >= timeout_; } -- cgit