]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/atomic/include/boost/atomic/detail/atomic_flag.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / atomic / include / boost / atomic / detail / atomic_flag.hpp
1 /*
2 * Distributed under the Boost Software License, Version 1.0.
3 * (See accompanying file LICENSE_1_0.txt or copy at
4 * http://www.boost.org/LICENSE_1_0.txt)
5 *
6 * Copyright (c) 2014 Andrey Semashev
7 */
8 /*!
9 * \file atomic/detail/atomic_flag.hpp
10 *
11 * This header contains interface definition of \c atomic_flag.
12 */
13
14 #ifndef BOOST_ATOMIC_DETAIL_ATOMIC_FLAG_HPP_INCLUDED_
15 #define BOOST_ATOMIC_DETAIL_ATOMIC_FLAG_HPP_INCLUDED_
16
17 #include <boost/assert.hpp>
18 #include <boost/memory_order.hpp>
19 #include <boost/atomic/detail/config.hpp>
20 #include <boost/atomic/detail/operations_lockfree.hpp>
21
22 #ifdef BOOST_HAS_PRAGMA_ONCE
23 #pragma once
24 #endif
25
26 /*
27 * IMPLEMENTATION NOTE: All interface functions MUST be declared with BOOST_FORCEINLINE,
28 * see comment for convert_memory_order_to_gcc in ops_gcc_atomic.hpp.
29 */
30
31 namespace boost {
32 namespace atomics {
33
34 #if defined(BOOST_NO_CXX11_CONSTEXPR) || defined(BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX)
35 #define BOOST_ATOMIC_NO_ATOMIC_FLAG_INIT
36 #else
37 #define BOOST_ATOMIC_FLAG_INIT {}
38 #endif
39
40 struct atomic_flag
41 {
42 typedef atomics::detail::operations< 1u, false > operations;
43 typedef operations::storage_type storage_type;
44
45 operations::aligned_storage_type m_storage;
46
47 BOOST_FORCEINLINE BOOST_CONSTEXPR atomic_flag() BOOST_NOEXCEPT : m_storage(0)
48 {
49 }
50
51 BOOST_FORCEINLINE bool test_and_set(memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
52 {
53 return operations::test_and_set(m_storage.value, order);
54 }
55
56 BOOST_FORCEINLINE void clear(memory_order order = memory_order_seq_cst) volatile BOOST_NOEXCEPT
57 {
58 BOOST_ASSERT(order != memory_order_acquire);
59 BOOST_ASSERT(order != memory_order_acq_rel);
60 operations::clear(m_storage.value, order);
61 }
62
63 BOOST_DELETED_FUNCTION(atomic_flag(atomic_flag const&))
64 BOOST_DELETED_FUNCTION(atomic_flag& operator= (atomic_flag const&))
65 };
66
67 } // namespace atomics
68 } // namespace boost
69
70 #endif // BOOST_ATOMIC_DETAIL_ATOMIC_FLAG_HPP_INCLUDED_