1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #include "ThreadDelay.h"
8 #include "mozilla/Assertions.h"
9 #include "mozilla/ChaosMode.h"
19 void DelayForChaosMode(ChaosFeature aFeature
,
20 const uint32_t aMicrosecondLimit
) {
21 if (!ChaosMode::isActive(aFeature
)) {
25 MOZ_ASSERT(aMicrosecondLimit
<= 1000);
27 // Windows doesn't support sleeping at less than millisecond resolution.
28 // We could spin here, or we could just sleep for one millisecond.
29 // Sleeping for a full millisecond causes heavy delays, so we don't do
30 // anything here for now until we have found a good way to sleep more
33 const uint32_t duration
= ChaosMode::randomUint32LessThan(aMicrosecondLimit
);
38 } // namespace mozilla