• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2023 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // GlobalMutex.h: Defines Global Mutex and utilities.
7 
8 #ifndef LIBANGLE_GLOBAL_MUTEX_H_
9 #define LIBANGLE_GLOBAL_MUTEX_H_
10 
11 #include "common/angleutils.h"
12 
13 namespace egl
14 {
15 namespace priv
16 {
17 class GlobalMutex;
18 }  // namespace priv
19 
20 class [[nodiscard]] ScopedGlobalMutexLock final : angle::NonCopyable
21 {
22   public:
23     ScopedGlobalMutexLock();
24     ~ScopedGlobalMutexLock();
25 
26 #if !defined(ANGLE_ENABLE_GLOBAL_MUTEX_LOAD_TIME_ALLOCATE)
27   private:
28     priv::GlobalMutex &mMutex;
29 #endif
30 };
31 
32 // For Context protection where lock is optional. Works slower than ScopedGlobalMutexLock.
33 class [[nodiscard]] ScopedOptionalGlobalMutexLock final : angle::NonCopyable
34 {
35   public:
36     explicit ScopedOptionalGlobalMutexLock(bool enabled);
37     ~ScopedOptionalGlobalMutexLock();
38 
39   private:
40     priv::GlobalMutex *mMutex;
41 };
42 
43 #if defined(ANGLE_PLATFORM_WINDOWS) && !defined(ANGLE_STATIC)
44 void AllocateGlobalMutex();
45 void DeallocateGlobalMutex();
46 #endif
47 
48 }  // namespace egl
49 
50 #endif  // LIBANGLE_GLOBAL_MUTEX_H_
51