コード例 #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+='/';
    }
  }
コード例 #2
0
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()!='/'));
}