void addTrailingSlashIfMissing(boost::synchronized_value<std::string> & path) { boost::strict_lock_ptr<std::string> u=path.synchronize(); if(u->empty() || (*u->rbegin()!='/')) { *u+='/'; } }
void store_lines_from_robotstxt_and_output_them(const std::string &host) { std::string robotstxt = get_robotstxt(host); std::istringstream is(robotstxt); std::string s; while (std::getline(is, s)) { auto p = lines.synchronize(); p->emplace_back(s); } // wait() blocks until the required number of threads has called wait(); // wait() returns true for only one thread if (barrier.wait()) { // value() provides unsynchronized access (no synchronization required // as only one thread iterates over and outputs the lines) for (auto &line : lines.value()) std::cout << line << '\n'; } }
bool checkIfMissingTrailingSlash(boost::synchronized_value<std::string> & path) { boost::strict_lock_ptr<std::string> u=path.synchronize(); return (u->empty() || (*u->rbegin()!='/')); }