diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-15 07:22:24 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2016-09-15 07:22:24 +0000 |
commit | 9a79125352dd793435960c773f144aa38860512e (patch) | |
tree | f46c47328ffca67de1bd8a49c4d5f987bdf0f48b /filedistribution | |
parent | d2f95fe18f5d1455b1ad09c3224409680b3e4976 (diff) |
No BOOST_FOREACH magic
Diffstat (limited to 'filedistribution')
6 files changed, 20 insertions, 33 deletions
diff --git a/filedistribution/src/apps/status/status-filedistribution.cpp b/filedistribution/src/apps/status/status-filedistribution.cpp index 3818be337eb..d7dc62e29c4 100644 --- a/filedistribution/src/apps/status/status-filedistribution.cpp +++ b/filedistribution/src/apps/status/status-filedistribution.cpp @@ -8,7 +8,6 @@ LOG_SETUP("status-filedistribution"); #include <thread> #include <boost/program_options.hpp> -#include <boost/foreach.hpp> #include <vespa/filedistribution/model/zkfacade.h> #include <vespa/filedistribution/model/filedistributionmodel.h> @@ -17,6 +16,7 @@ LOG_SETUP("status-filedistribution"); using namespace filedistribution; using namespace std::literals; +namespace po = boost::program_options; std::string plural(size_t size) @@ -42,7 +42,7 @@ void printWaitingForHosts(const StatusByHostName& notFinishedHosts) { std::cout <<"Waiting for the following host" <<plural(notFinishedHosts) <<":" <<std::endl; - BOOST_FOREACH(const StatusByHostName::value_type hostNameAndStatus, notFinishedHosts) { + for (const StatusByHostName::value_type & hostNameAndStatus : notFinishedHosts) { std::cout <<hostNameAndStatus.first <<" ("; const HostStatus& hostStatus = hostNameAndStatus.second; @@ -70,7 +70,7 @@ int printStatus(const std::string& zkservers) StatusByHostName finishedHosts; bool hasStarted = false; - BOOST_FOREACH(std::string host, hosts) { + for (const std::string & host : hosts) { HostStatus hostStatus = model->getHostStatus(host); switch (hostStatus._state) { case HostStatus::finished: @@ -131,12 +131,11 @@ struct ProgramOptionException { {} }; -bool exists(const std::string& optionName, const boost::program_options::variables_map& map) { +bool exists(const std::string& optionName, const po::variables_map& map) { return map.find(optionName) != map.end(); } -void ensureExists(const std::string& optionName, const boost::program_options::variables_map& map \ - ) { +void ensureExists(const std::string& optionName, const po::variables_map& map) { if (!exists(optionName, map)) { throw ProgramOptionException("Error: Missing option " + optionName); } @@ -151,18 +150,15 @@ main(int argc, char** argv) { *zkLogFile = "zkLogFile", *help = "help"; - namespace po = boost::program_options; - boost::program_options::options_description description; + po::options_description description; description.add_options() (zkstring, po::value<std::string > (), "The zookeeper servers to connect to, separated by comma") (zkLogFile, po::value<std::string >() -> default_value("/dev/null"), "Zookeeper log file") (help, "help"); try { - boost::program_options::variables_map values; - po::store( - boost::program_options::parse_command_line(argc, argv, description), - values); + po::variables_map values; + po::store(po::parse_command_line(argc, argv, description), values); if (exists(help, values)) { std::cout <<description; diff --git a/filedistribution/src/tests/status/test-status.cpp b/filedistribution/src/tests/status/test-status.cpp index cfa3e740093..4fbda2cb9c3 100644 --- a/filedistribution/src/tests/status/test-status.cpp +++ b/filedistribution/src/tests/status/test-status.cpp @@ -3,7 +3,6 @@ #define BOOST_TEST_MAIN #include <vespa/fastos/fastos.h> #include <boost/test/unit_test.hpp> -#include <boost/foreach.hpp> #include <vespa/filedistribution/model/zkfacade.h> #include <vespa/filedistribution/model/filedistributionmodel.h> diff --git a/filedistribution/src/vespa/filedistribution/common/componentsdeleter.cpp b/filedistribution/src/vespa/filedistribution/common/componentsdeleter.cpp index 124ce5d0472..053073b26e5 100644 --- a/filedistribution/src/vespa/filedistribution/common/componentsdeleter.cpp +++ b/filedistribution/src/vespa/filedistribution/common/componentsdeleter.cpp @@ -5,8 +5,6 @@ #include <vespa/log/log.h> LOG_SETUP(".componentsdeleter"); -#include <boost/foreach.hpp> - using namespace std::literals; using namespace filedistribution; @@ -75,7 +73,7 @@ void ComponentsDeleter::logNotDeletedComponents() { LockGuard guard(_trackedComponentsMutex); - BOOST_FOREACH(TrackedComponentsMap::value_type component, _trackedComponents) { + for (const auto & component : _trackedComponents) { LOG(info, "Timed out waiting for component '%s' to be deleted", component.second.c_str()); } } diff --git a/filedistribution/src/vespa/filedistribution/distributor/filedownloader.cpp b/filedistribution/src/vespa/filedistribution/distributor/filedownloader.cpp index 0b213953435..7d5d7acceb2 100644 --- a/filedistribution/src/vespa/filedistribution/distributor/filedownloader.cpp +++ b/filedistribution/src/vespa/filedistribution/distributor/filedownloader.cpp @@ -10,7 +10,6 @@ #include <boost/filesystem/fstream.hpp> #include <boost/filesystem/convenience.hpp> #include <boost/function_output_iterator.hpp> -#include <boost/foreach.hpp> #include <libtorrent/alert.hpp> #include <libtorrent/alert_types.hpp> @@ -173,11 +172,9 @@ struct FileDownloader::EventHandler void operator()(const libtorrent::save_resume_data_alert& alert) const { defaultHandler(alert); - fs::ofstream resumeFile(resumeDataPathTemp(alert.handle), - std::ios_base::binary); + fs::ofstream resumeFile(resumeDataPathTemp(alert.handle), std::ios_base::binary); resumeFile.unsetf(std::ios_base::skipws); - libtorrent::bencode(std::ostream_iterator<char>(resumeFile), - *alert.resume_data); + libtorrent::bencode(std::ostream_iterator<char>(resumeFile), *alert.resume_data); resumeFile.close(); fs::rename(resumeDataPathTemp(alert.handle), resumeDataPath(alert.handle)); _fileDownloader.didReceiveSRD(); @@ -355,17 +352,16 @@ FileDownloader::removeAllTorrentsBut(const std::set<std::string> & filesToRetain std::set<std::string> currentFiles; std::set<sha1_hash> infoHashesToRetain; - BOOST_FOREACH(const std::string& fileReference, filesToRetain) { + for (const std::string& fileReference : filesToRetain) { infoHashesToRetain.insert(toInfoHash(fileReference)); } std::vector<torrent_handle> torrents = _session.get_torrents(); - BOOST_FOREACH(torrent_handle torrent, torrents) { + for (torrent_handle torrent : torrents) { if (!infoHashesToRetain.count(torrent.info_hash())) { LOG(info, "Removing torrent: '%s' with file reference '%s'", - getMainName(torrent).c_str(), - fileReferenceToString(torrent.info_hash()).c_str()); + getMainName(torrent).c_str(), fileReferenceToString(torrent.info_hash()).c_str()); deleteTorrentData(torrent, guard); _session.remove_torrent(torrent); diff --git a/filedistribution/src/vespa/filedistribution/model/zkfiledbmodel.cpp b/filedistribution/src/vespa/filedistribution/model/zkfiledbmodel.cpp index 17fdba96862..70827305138 100644 --- a/filedistribution/src/vespa/filedistribution/model/zkfiledbmodel.cpp +++ b/filedistribution/src/vespa/filedistribution/model/zkfiledbmodel.cpp @@ -10,7 +10,6 @@ #include "deployedfilestodownload.h" #include <vespa/filedistribution/common/logfwd.h> #include <sys/file.h> -#include <boost/foreach.hpp> namespace fs = boost::filesystem; @@ -205,7 +204,7 @@ ZKFileDBModel::getHostStatus(const std::string& hostName) { hostStatus._numFilesToDownload = filesToDownload.size(); hostStatus._numFilesFinished = 0; - BOOST_FOREACH(std::string file, filesToDownload) { + for (const std::string & file : filesToDownload) { Path path = getPeersPath(file); const PeerEntries peerEntries = getSortedChildren(*_zk, path); @@ -258,8 +257,7 @@ ZKFileDBModel::getProgress(const Path& path) { else if (buffer.size() == 0) return 0; else { - throw boost::enable_current_exception(InvalidProgressException()) - <<errorinfo::Path(path); + throw boost::enable_current_exception(InvalidProgressException()) <<errorinfo::Path(path); } } catch (ZKNodeDoesNotExistsException& e) { //progress information deleted @@ -279,7 +277,7 @@ ZKFileDBModel::getProgress(const std::string& fileReference, const PeerEntries peerEntries = getSortedChildren(*_zk, path); PeerEntries::const_iterator current = peerEntries.begin(); - BOOST_FOREACH(const std::string& host, hostsSortedAscending) { + for (const std::string& host : hostsSortedAscending) { PeerEntries::const_iterator candidate = std::lower_bound(current, peerEntries.end(), host); diff --git a/filedistribution/src/vespa/filedistribution/rpc/filedistributorrpc.cpp b/filedistribution/src/vespa/filedistribution/rpc/filedistributorrpc.cpp index 9e0c8e87af6..6579ea06f31 100644 --- a/filedistribution/src/vespa/filedistribution/rpc/filedistributorrpc.cpp +++ b/filedistribution/src/vespa/filedistribution/rpc/filedistributorrpc.cpp @@ -3,7 +3,6 @@ #include "filedistributorrpc.h" #include <boost/optional.hpp> -#include <boost/foreach.hpp> #include <boost/exception/diagnostic_information.hpp> #include <vespa/log/log.h> @@ -45,7 +44,8 @@ class QueuedRequests { typedef Map::iterator iterator; std::pair<iterator, iterator> range = _queuedRequests.equal_range(fileReference); - BOOST_FOREACH( const Map::value_type& request, range) { + for (iterator it(range.first); it != range.second; it++) { + const Map::value_type & request(*it); LOG(info, "Returning earlier enqueued request for file reference '%s'.", request.first.c_str()); func(*request.second); request.second->Return(); @@ -131,7 +131,7 @@ public: LockGuard guard(_mutex); _shuttingDown = true; - BOOST_FOREACH( const Map::value_type& request, _queuedRequests) { + for (const Map::value_type& request : _queuedRequests) { LOG(info, "Shutdown: Aborting earlier enqueued request for file reference '%s'.", request.first.c_str()); abort(request.second); } |