chromium/third_party/blink/renderer/platform/scheduler/common/thread_cpu_throttler.cc

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

#include "third_party/blink/renderer/platform/scheduler/public/thread_cpu_throttler.h"

#include <atomic>
#include <memory>

#include "base/logging.h"
#include "base/memory/singleton.h"
#include "base/synchronization/atomic_flag.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "build/build_config.h"

#if BUILDFLAG(IS_POSIX)
#include <signal.h>
#define USE_SIGNALS
#elif BUILDFLAG(IS_WIN)
#include <windows.h>
#endif

namespace blink {
namespace scheduler {

class ThreadCPUThrottler::ThrottlingThread final
    : public base::PlatformThread::Delegate {};

#ifdef USE_SIGNALS
bool ThreadCPUThrottler::ThrottlingThread::signal_handler_installed_;
struct sigaction ThreadCPUThrottler::ThrottlingThread::old_signal_handler_;
#endif
std::atomic<int> ThreadCPUThrottler::ThrottlingThread::throttling_rate_percent_;
std::atomic<bool> ThreadCPUThrottler::ThrottlingThread::thread_exists_;

ThreadCPUThrottler::ThrottlingThread::ThrottlingThread(double rate)
#ifdef OS_WIN
    :{}  // namespace scheduler

ThreadCPUThrottler::ThrottlingThread::~ThrottlingThread() {}

void ThreadCPUThrottler::ThrottlingThread::SetThrottlingRate(double rate) {}

void ThreadCPUThrottler::ThrottlingThread::ThreadMain() {}

#ifdef USE_SIGNALS

// static
void ThreadCPUThrottler::ThrottlingThread::InstallSignalHandler() {}

// static
void ThreadCPUThrottler::ThrottlingThread::RestoreSignalHandler() {}

// static
void ThreadCPUThrottler::ThrottlingThread::HandleSignal(int signal) {}

#endif  // USE_SIGNALS

void ThreadCPUThrottler::ThrottlingThread::Throttle() {}

void ThreadCPUThrottler::ThrottlingThread::Start() {}

void ThreadCPUThrottler::ThrottlingThread::Sleep(base::TimeDelta duration) {}

void ThreadCPUThrottler::ThrottlingThread::Stop() {}

ThreadCPUThrottler::ThreadCPUThrottler() = default;
ThreadCPUThrottler::~ThreadCPUThrottler() = default;

void ThreadCPUThrottler::SetThrottlingRate(double rate) {}

// static
ThreadCPUThrottler* ThreadCPUThrottler::GetInstance() {}

}  // namespace scheduler
}  // namespace blink