1 //===-- mutex.h -------------------------------------------------*- C++ -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #ifndef GWP_ASAN_MUTEX_H_
10 #define GWP_ASAN_MUTEX_H_
12 #include "gwp_asan/platform_specific/mutex_fuchsia.h" // IWYU pragma: keep
13 #include "gwp_asan/platform_specific/mutex_posix.h" // IWYU pragma: keep
16 class Mutex final
: PlatformMutex
{
18 constexpr Mutex() = default;
20 Mutex(const Mutex
&) = delete;
21 Mutex
&operator=(const Mutex
&) = delete;
24 // Nonblocking trylock of the mutex. Returns true if the lock was acquired.
32 explicit ScopedLock(Mutex
&Mx
) : Mu(Mx
) { Mu
.lock(); }
33 ~ScopedLock() { Mu
.unlock(); }
34 ScopedLock(const ScopedLock
&) = delete;
35 ScopedLock
&operator=(const ScopedLock
&) = delete;
40 } // namespace gwp_asan
42 #endif // GWP_ASAN_MUTEX_H_