blob: f16cbeca8ab7290164c0abbf48e2fc72f110b4df [file] [log] [blame]
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/base_export.h"
#include "base/feature_list.h"
#include "base/optional.h"
#include "build/build_config.h"
namespace base {
class Location;
enum class ThreadPriority : int;
// This class must be instantiated in every scope where a DLL can be loaded on
// a background thread. On Windows, loading a DLL on a background thread can
// lead to a priority inversion on the loader lock and cause huge janks.
class BASE_EXPORT ScopedThreadMayLoadLibraryOnBackgroundThread {
explicit ScopedThreadMayLoadLibraryOnBackgroundThread(
const Location& from_here);
#if defined(OS_WIN)
// The original priority when entering the scope.
base::Optional<ThreadPriority> original_thread_priority_;
// Feature for mitigation of DLL loading on a background thread.
#if defined(OS_WIN)
BASE_EXPORT extern const base::Feature kBoostThreadPriorityOnLibraryLoading;
#endif // OS_WIN
} // namespace base