예제 #1
0
  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';
	}
}
예제 #3
0
파일: os.cpp 프로젝트: ZhaozhengPlus/libqi
 static Uuid uuidGenerator()
 {
   static boost::synchronized_value<UuidRandomGenerator> g;
   return g->operator()();
 }
예제 #4
0
bool checkIfMissingTrailingSlash(boost::synchronized_value<std::string> & path)
{
  boost::strict_lock_ptr<std::string> u=path.synchronize();

  return (u->empty() || (*u->rbegin()!='/'));
}