#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)
BASE_FEATURE(kSkipConditionVariableWakeupHack,
"SkipConditionVariableWakeupHack",
base::FEATURE_ENABLED_BY_DEFAULT);
std::atomic_bool g_skip_wakeup_hack = true;
#endif
}
namespace base {
ConditionVariable::ConditionVariable(Lock* user_lock)
: … { … }
ConditionVariable::~ConditionVariable() { … }
#if BUILDFLAG(IS_APPLE)
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() { … }
}