Arene Base
Fundamental Utilities For Safety Critical C++
Loading...
Searching...
No Matches
lock_guard.hpp
Go to the documentation of this file.
1
// Copyright 2026, Toyota Motor Corporation
2
//
3
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4
5
///
6
/// @file lock_guard.hpp
7
/// @brief Exports either a TSA annotated wrapper or a simple alias of std::lock_guard as needed.
8
///
9
10
#ifndef INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MUTEX_LOCK_GUARD_HPP_
11
#define INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MUTEX_LOCK_GUARD_HPP_
12
13
// IWYU pragma: private, include "arene/base/mutex.hpp"
14
// IWYU pragma: friend "(arene/base(?!/tests)|stdlib/include/stdlib_detail)/.*"
15
16
// parasoft-begin-suppress AUTOSAR-A16_2_2-a-2 "Arene Base aggregate headers permitted by A16-2-2 Permit #1"
17
#include "
arene/base/compiler_support/platform_queries.hpp
"
18
#include "
arene/base/compiler_support/preprocessor.hpp
"
19
20
#if ARENE_IS_ON(ARENE_HAS_THREAD_SAFETY_ANALYSIS) && ARENE_IS_OFF(ARENE_STDLIB_LIBCXX)
21
#include "arene/base/mutex/detail/lock_guard.hpp"
22
#else
23
#include "arene/base/mutex/detail/only_aliases.hpp"
24
#endif
25
26
// parasoft-end-suppress AUTOSAR-A16_2_2-a-2
27
28
namespace
arene
{
29
namespace
base
{
30
31
///
32
/// @brief A lock guard suitable for use with clang's Thread Safety Analysis. Equivalent to @c std::lock_guard.
33
///
34
/// If Thread Safety Analysis is not supported by the current compiler, or the current stdlib already has a TSA
35
/// annotated @c std::lock_guard, then this is a simple alias to @c std::lock_guard. Otherwise it is a thin wrapper
36
/// around @c std::lock_guard which annotates it as a _scoped capability_, but is otherwise identical to
37
/// @c std::lock_guard.
38
///
39
/// @note The support for Thread Safety Analysis is detected by the @c ARENE_HAS_THREAD_SAFETY_ANALYSIS platform query.
40
/// @note Currently, only libcxx has an out of the box annotated implementation. Detection is done via the
41
/// @c ARENE_STDLIB_LIBCXX platform query.
42
///
43
/// @tparam Mutex the type of the mutex to guard.
44
///
45
template
<
typename
Mutex>
46
using
lock_guard
= mutex_detail::selected_lock_guard<Mutex>;
47
48
}
// namespace base
49
}
// namespace arene
50
51
#endif
// INCLUDE_GUARD_ARENE_BASE_ARENE_BASE_MUTEX_LOCK_GUARD_HPP_
arene::base
Definition
accumulate.hpp:37
arene::base::lock_guard
mutex_detail::selected_lock_guard< Mutex > lock_guard
A lock guard suitable for use with clang's Thread Safety Analysis. Equivalent to std::lock_guard.
Definition
lock_guard.hpp:46
arene
Definition
accumulate.hpp:36
platform_queries.hpp
preprocessor.hpp
arene
base
mutex
lock_guard.hpp
Generated by
1.13.2