本文整理汇总了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);
}
}
}