/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Some versions of the Windows SDK have a bug where some interlocked functions // are not redefined as compiler intrinsics. Fix that for the interlocked // functions that are used in this file. #ifdefined(_MSC_VER) && !defined(InterlockedExchangeAdd) # define InterlockedExchangeAdd(addend, value) \
_InterlockedExchangeAdd((volatilelong*)(addend), (long)(value)) #endif
// Note that DWORD is unsigned, so we have to be careful to clamp at 0. If // rel_time is Forever, then ToMilliseconds is +inf, which evaluates as // greater than UINT32_MAX, resulting in the correct INFINITE wait. We also // don't want to round sub-millisecond waits to 0, as that wastes energy (see // bug 1437167 comment 6), so we instead round submillisecond waits to 1ms. double msecd = rel_time.ToMilliseconds();
DWORD msec; if (msecd < 0.0) {
msec = 0;
} elseif (msecd > UINT32_MAX) {
msec = INFINITE;
} else {
msec = static_cast<DWORD>(msecd); // Round submillisecond waits to 1ms. if (msec == 0 && !rel_time.IsZero()) {
msec = 1;
}
}
BOOL r = SleepConditionVariableSRW(&platformData()->cv_, srwlock, msec, 0); if (r) return CVStatus::NoTimeout;
MOZ_RELEASE_ASSERT(GetLastError() == ERROR_TIMEOUT); return CVStatus::Timeout;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.