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


C++ atomic::fetch_or方法代码示例

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


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

示例1: lock

void
handleDbgBreakInterrupt()
{
   // If we are not initialised, we should ignore DbgBreaks
   if (!decaf::config::debugger::enabled) {
      return;
   }

   std::unique_lock<std::mutex> lock(sMutex);
   auto coreId = cpu::this_core::id();

   // Store our core state before we flip isPaused
   sCorePauseState[coreId] = cpu::this_core::state();

   // Check to see if we were the last core to join on the fun
   auto coreBit = 1 << coreId;
   auto isPausing = sIsPausing.fetch_or(coreBit);

   if (isPausing == 0) {
      // This is the first core to hit a breakpoint
      sPauseInitiatorCoreId = coreId;

      // Signal the rest of the cores to stop
      for (auto i = 0; i < 3; ++i) {
         cpu::interrupt(i, cpu::DBGBREAK_INTERRUPT);
      }
   }

   if ((isPausing | coreBit) == (1 | 2 | 4)) {
      // This was the last core to join.
      sIsPaused.store(true);
      sIsPausing.store(0);
      sIsResuming.store(0);
   }

   // Spin around the release condition while we are paused
   while (sIsPausing.load() || sIsPaused.load()) {
      sPauseReleaseCond.wait(lock);
   }

   // Clear any additional DbgBreaks that occured
   cpu::this_core::clearInterrupt(cpu::DBGBREAK_INTERRUPT);

   // Everyone needs to leave at once in case new breakpoints occur.
   if ((sIsResuming.fetch_or(coreBit) | coreBit) == (1 | 2 | 4)) {
      sPauseReleaseCond.notify_all();
   } else {
      while ((sIsResuming.load() | coreBit) != (1 | 2 | 4)) {
         sPauseReleaseCond.wait(lock);
      }
   }
}
开发者ID:achurch,项目名称:decaf-emu,代码行数:52,代码来源:debugger.cpp


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