Path: blob/main/contrib/llvm-project/compiler-rt/lib/scudo/standalone/condition_variable.h
35292 views
//===-- condition_variable.h ------------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef SCUDO_CONDITION_VARIABLE_H_9#define SCUDO_CONDITION_VARIABLE_H_1011#include "condition_variable_base.h"1213#include "common.h"14#include "platform.h"1516#include "condition_variable_linux.h"1718namespace scudo {1920// A default implementation of default condition variable. It doesn't do a real21// `wait`, instead it spins a short amount of time only.22class ConditionVariableDummy23: public ConditionVariableBase<ConditionVariableDummy> {24public:25void notifyAllImpl(UNUSED HybridMutex &M) REQUIRES(M) {}2627void waitImpl(UNUSED HybridMutex &M) REQUIRES(M) {28M.unlock();2930constexpr u32 SpinTimes = 64;31volatile u32 V = 0;32for (u32 I = 0; I < SpinTimes; ++I) {33u32 Tmp = V + 1;34V = Tmp;35}3637M.lock();38}39};4041} // namespace scudo4243#endif // SCUDO_CONDITION_VARIABLE_H_444546