当前位置: 首页>>代码示例>>C++>>正文


C++ condition_variable::wait_for方法代码示例

本文整理汇总了C++中condition_variable::wait_for方法的典型用法代码示例。如果您正苦于以下问题:C++ condition_variable::wait_for方法的具体用法?C++ condition_variable::wait_for怎么用?C++ condition_variable::wait_for使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在condition_variable的用法示例。


在下文中一共展示了condition_variable::wait_for方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: wait_for

			bool wait_for(int64_t wait_time_us)
			{
				if (!sync)
					return false;
				unique_lock<mutex> lk{m};
				return cv.wait_for(lk, chrono::microseconds(wait_time_us), [this]{return rdy;});
			}
开发者ID:jhbsz,项目名称:kappaBox-SDK,代码行数:7,代码来源:aps_data_service_ext_impl.hpp

示例2: test

void test(SBDebugger &dbg, vector<string> args) {
  SBTarget target = dbg.CreateTarget(args.at(0).c_str());
  if (!target.IsValid()) throw Exception("invalid target");

  SBBreakpoint breakpoint = target.BreakpointCreateByName("next");
  if (!breakpoint.IsValid()) throw Exception("invalid breakpoint");
  breakpoint.SetCallback(BPCallback, 0);

  std::unique_ptr<char> working_dir(get_working_dir());
  SBProcess process = target.LaunchSimple (0, 0, working_dir.get());

  {
    unique_lock<mutex> lock(g_mutex);
    g_condition.wait_for(lock, chrono::seconds(5));
    if (g_breakpoint_hit_count != 1)
      throw Exception("Breakpoint hit count expected to be 1");
  }
}
开发者ID:Jean-Daniel,项目名称:lldb,代码行数:18,代码来源:test_breakpoint_callback.cpp

示例3: Thread

void SwitcherData::Thread()
{
	chrono::duration<long long, milli> duration =
		chrono::milliseconds(interval);
	string lastTitle;
	string title;

	for (;;) {
		unique_lock<mutex> lock(m);
		OBSWeakSource scene;
		bool match = false;

		cv.wait_for(lock, duration);
		if (switcher->stop) {
			switcher->stop = false;
			break;
		}

		duration = chrono::milliseconds(interval);

		GetCurrentWindowTitle(title);

		if (lastTitle != title) {
			switcher->Prune();

			for (SceneSwitch &s : switches) {
				if (s.window == title) {
					match = true;
					scene = s.scene;
					break;
				}
			}

			/* try regex */
			if (!match) {
				for (SceneSwitch &s : switches) {
					try {
						bool matches = regex_match(
								title, s.re);
						if (matches) {
							match = true;
							scene = s.scene;
							break;
						}
					} catch (const regex_error &) {}
				}
			}

			if (!match && switchIfNotMatching &&
					nonMatchingScene) {
				match = true;
				scene = nonMatchingScene;
			}

			if (match) {
				obs_source_t *source =
					obs_weak_source_get_source(scene);
				obs_source_t *currentSource =
					obs_frontend_get_current_scene();

				if (source && source != currentSource)
					obs_frontend_set_current_scene(source);

				obs_source_release(currentSource);
				obs_source_release(source);
			}
		}

		lastTitle = title;
	}
}
开发者ID:AnthonySuper,项目名称:obs-studio,代码行数:71,代码来源:auto-scene-switcher.cpp

示例4: CPU_WaitStatus

void CPU_WaitStatus(bool (*pred)()) {
	cpuThreadLock.lock();
	while (!pred())
		cpuThreadCond.wait_for(cpuThreadLock, 16);
	cpuThreadLock.unlock();
}
开发者ID:KingPepper,项目名称:ppsspp,代码行数:6,代码来源:System.cpp

示例5: waitForCountAndFailOnTimeout

 void waitForCountAndFailOnTimeout(unsigned int expectedCount,
                                   const milliseconds& time = milliseconds(100)) {
     unique_lock<mutex> lock(m);
     ASSERT_TRUE(wasExecuted.wait_for(lock, time, [&] {return expectedCount == count;}));
 }
开发者ID:Seitseman,项目名称:StudyTDD-,代码行数:5,代码来源:ThreadPoolTest.cpp


注:本文中的condition_variable::wait_for方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。