本文整理汇总了C++中mozilla::Atomic类的典型用法代码示例。如果您正苦于以下问题:C++ Atomic类的具体用法?C++ Atomic怎么用?C++ Atomic使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Atomic类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Push
bool Push(int i) {
while (!mWriting.compareExchange(false, true)) {
}
mDQ.PushFront(reinterpret_cast<void*>(static_cast<uintptr_t>(i)));
mWriting = false;
return true;
}
示例2: vsnprintf
MFBT_API MOZ_COLD MOZ_NORETURN MOZ_NEVER_INLINE MOZ_FORMAT_PRINTF(3, 4) void
MOZ_CrashPrintf(const char* aFilename, int aLine, const char* aFormat, ...)
#endif
{
if (!sCrashing.compareExchange(false, true)) {
// In the unlikely event of a race condition, skip
// setting the crash reason and just crash safely.
MOZ_REALLY_CRASH(aLine);
}
va_list aArgs;
va_start(aArgs, aFormat);
int ret = vsnprintf(sPrintfCrashReason, sPrintfCrashReasonSize,
aFormat, aArgs);
va_end(aArgs);
MOZ_RELEASE_ASSERT(ret >= 0 && size_t(ret) < sPrintfCrashReasonSize,
"Could not write the explanation string to the supplied buffer!");
#ifdef DEBUG
MOZ_ReportCrash(sPrintfCrashReason, aFilename, aLine);
#endif
gMozCrashReason = sPrintfCrashReason;
MOZ_REALLY_CRASH(aLine);
}
示例3: if
static void
UnixExceptionHandler(int signum, siginfo_t* info, void* context)
{
// Make absolutely sure we can only get here once.
if (sHandlingException.compareExchange(false, true)) {
// Restore the previous handler. We're going to forward to it
// anyway, and if we crash while doing so we don't want to hang.
MOZ_ALWAYS_FALSE(sigaction(SIGSEGV, &sPrevSEGVHandler, nullptr));
MOZ_ASSERT(signum == SIGSEGV && info->si_signo == SIGSEGV);
if (info->si_code == SEGV_ACCERR) {
// Get the address that the offending code tried to access.
uintptr_t address = uintptr_t(info->si_addr);
// If the faulting address is in one of our protected regions, we
// want to annotate the crash to make it stand out from the crowd.
if (sProtectedRegions.isProtected(address)) {
ReportCrashIfDebug("Hit MOZ_CRASH(Tried to access a protected region!)\n");
MOZ_CRASH_ANNOTATE("MOZ_CRASH(Tried to access a protected region!)");
}
}
}
// Forward to the previous handler which may be a debugger,
// the crash reporter or something else entirely.
if (sPrevSEGVHandler.sa_flags & SA_SIGINFO)
sPrevSEGVHandler.sa_sigaction(signum, info, context);
else if (sPrevSEGVHandler.sa_handler == SIG_DFL || sPrevSEGVHandler.sa_handler == SIG_IGN)
sigaction(SIGSEGV, &sPrevSEGVHandler, nullptr);
else
sPrevSEGVHandler.sa_handler(signum);
// If we reach here, we're returning to let the default signal handler deal
// with the exception. This is technically undefined behavior, but
// everything seems to do it, and it removes us from the crash stack.
}
示例4: AutoWalkJSStack
AutoWalkJSStack() : walkAllowed(false) {
walkAllowed = WALKING_JS_STACK.compareExchange(false, true);
}