Debian Codegraph @

mozglue/misc/PlatformMutex.h

raw ◀ ▶
1 Debian patch touch this file
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6
7 #ifndef mozilla_PlatformMutex_h
8 #define mozilla_PlatformMutex_h
9
10 #include <utility>
11
12 #include "mozilla/Attributes.h"
13 #include "mozilla/Types.h"
14
15 #if !defined(XP_WIN) && !defined(__wasi__)
16 # include <pthread.h>
17 #endif
18
19 namespace mozilla {
20
21 namespace detail {
22
23 class ConditionVariableImpl;
24
25 class MutexImpl {
26 public:
27 struct PlatformData;
28
29 explicit MFBT_API MutexImpl();
30 MFBT_API ~MutexImpl();
31
32 protected:
33 MFBT_API void lock();
34 MFBT_API void unlock();
35 // We have a separate, forwarding API so internal uses don't have to go
36 // through the PLT.
37 MFBT_API bool tryLock();
38
39 private:
40 MutexImpl(const MutexImpl&) = delete;
41 void operator=(const MutexImpl&) = delete;
42 MutexImpl(MutexImpl&&) = delete;
43 void operator=(MutexImpl&&) = delete;
44 bool operator==(const MutexImpl& rhs) = delete;
45
46 void mutexLock();
47 bool mutexTryLock();
48
49 PlatformData* platformData();
50
51 #if !defined(XP_WIN) && !defined(__wasi__)
•52 pthread_mutex_t platformData_[1];
53 #else
54 void* platformData_[6];
55 #endif
56
57 friend class mozilla::detail::ConditionVariableImpl;
58 };
59
60 } // namespace detail
61
62 } // namespace mozilla
63 #endif // mozilla_PlatformMutex_h