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/. */
7 #ifndef mozilla_PlatformMutex_h
8 #define mozilla_PlatformMutex_h
12 #include "mozilla/Attributes.h"
13 #include "mozilla/Types.h"
15 #if !defined(XP_WIN) && !defined(__wasi__)
23 class ConditionVariableImpl
;
29 explicit MFBT_API
MutexImpl();
30 MFBT_API
~MutexImpl();
34 MFBT_API
void unlock();
35 // We have a separate, forwarding API so internal uses don't have to go
37 MFBT_API
bool tryLock();
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;
49 PlatformData
* platformData();
51 #if !defined(XP_WIN) && !defined(__wasi__)
52 void* platformData_
[sizeof(pthread_mutex_t
) / sizeof(void*)];
53 static_assert(sizeof(pthread_mutex_t
) / sizeof(void*) != 0 &&
54 sizeof(pthread_mutex_t
) % sizeof(void*) == 0,
55 "pthread_mutex_t must have pointer alignment");
57 void* platformData_
[6];
60 friend class mozilla::detail::ConditionVariableImpl
;
65 } // namespace mozilla
66 #endif // mozilla_PlatformMutex_h