示例#1
0
	bool wait(duration_t* timeout) {
		std::unique_lock<std::mutex> guard(mutex);
		queue_lock->unlock();

		std::cv_status res = std::cv_status::no_timeout;

		if(timeout) {
			auto start = std::chrono::system_clock::now();
			res = ready.wait_for(guard, *timeout);	
			*timeout -= (std::chrono::system_clock::now() - start);
		} else {
			ready.wait(guard);
		}

		guard.unlock();
		queue_lock->lock();

		return res == std::cv_status::no_timeout;
	}
示例#2
0
文件: impl.cpp 项目: slon/raptor
	void before_switch_to() {
		lock->lock();
	}