chromium/base/synchronization/condition_variable_posix.cc

// Copyright 2011 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "base/synchronization/condition_variable.h"

#include <errno.h>
#include <stdint.h>
#include <sys/time.h>

#include <optional>

#include "base/synchronization/lock.h"
#include "base/threading/scoped_blocking_call.h"
#include "base/threading/thread_restrictions.h"
#include "base/time/time.h"
#include "build/build_config.h"

#if BUILDFLAG(IS_APPLE)
#include <atomic>

#include "base/feature_list.h"
#endif

#if BUILDFLAG(IS_ANDROID) && __ANDROID_API__ < 21
#define HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC
#endif

namespace {
#if BUILDFLAG(IS_APPLE)
// Under this feature a hack that was introduced to avoid crashes is skipped.
// Use to evaluate if the hack is still needed. See https://crbug.com/517681.
BASE_FEATURE(kSkipConditionVariableWakeupHack,
             "SkipConditionVariableWakeupHack",
             base::FEATURE_ENABLED_BY_DEFAULT);
std::atomic_bool g_skip_wakeup_hack = true;
#endif
}  // namespace

namespace base {

ConditionVariable::ConditionVariable(Lock* user_lock)
    :{}

ConditionVariable::~ConditionVariable() {}

#if BUILDFLAG(IS_APPLE)
// static
void ConditionVariable::InitializeFeatures() {
  g_skip_wakeup_hack.store(
      base::FeatureList::IsEnabled(kSkipConditionVariableWakeupHack),
      std::memory_order_relaxed);
}
#endif

void ConditionVariable::Wait() {}

void ConditionVariable::TimedWait(const TimeDelta& max_time) {}

void ConditionVariable::Broadcast() {}

void ConditionVariable::Signal() {}

}  // namespace base