Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:43:52

0001 /*
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * Copyright (c) 2020 Andrey Semashev
0007  */
0008 /*!
0009  * \file   atomic/ipc_atomic.hpp
0010  *
0011  * This header contains definition of \c ipc_atomic template.
0012  */
0013 
0014 #ifndef BOOST_ATOMIC_IPC_ATOMIC_HPP_INCLUDED_
0015 #define BOOST_ATOMIC_IPC_ATOMIC_HPP_INCLUDED_
0016 
0017 #include <cstddef>
0018 #include <boost/memory_order.hpp>
0019 #include <boost/atomic/capabilities.hpp>
0020 #include <boost/atomic/detail/config.hpp>
0021 #include <boost/atomic/detail/classify.hpp>
0022 #include <boost/atomic/detail/atomic_impl.hpp>
0023 #include <boost/atomic/detail/type_traits/is_trivially_copyable.hpp>
0024 #include <boost/atomic/detail/type_traits/is_nothrow_default_constructible.hpp>
0025 #include <boost/atomic/detail/header.hpp>
0026 
0027 #ifdef BOOST_HAS_PRAGMA_ONCE
0028 #pragma once
0029 #endif
0030 
0031 namespace boost {
0032 namespace atomics {
0033 
0034 //! Atomic object for inter-process communication
0035 template< typename T >
0036 class ipc_atomic :
0037     public atomics::detail::base_atomic< T, typename atomics::detail::classify< T >::type, true >
0038 {
0039 private:
0040     typedef atomics::detail::base_atomic< T, typename atomics::detail::classify< T >::type, true > base_type;
0041     typedef typename base_type::value_arg_type value_arg_type;
0042 
0043 public:
0044     typedef typename base_type::value_type value_type;
0045 
0046     static_assert(sizeof(value_type) > 0u, "boost::ipc_atomic<T> requires T to be a complete type");
0047 #if !defined(BOOST_ATOMIC_DETAIL_NO_CXX11_IS_TRIVIALLY_COPYABLE)
0048     static_assert(atomics::detail::is_trivially_copyable< value_type >::value, "boost::ipc_atomic<T> requires T to be a trivially copyable type");
0049 #endif
0050 
0051 public:
0052     BOOST_FORCEINLINE BOOST_ATOMIC_DETAIL_CONSTEXPR_UNION_INIT ipc_atomic() BOOST_NOEXCEPT_IF(atomics::detail::is_nothrow_default_constructible< value_type >::value) : base_type()
0053     {
0054     }
0055 
0056     BOOST_FORCEINLINE BOOST_ATOMIC_DETAIL_CONSTEXPR_UNION_INIT ipc_atomic(value_arg_type v) BOOST_NOEXCEPT : base_type(v)
0057     {
0058     }
0059 
0060     BOOST_FORCEINLINE value_type operator= (value_arg_type v) BOOST_NOEXCEPT
0061     {
0062         this->store(v);
0063         return v;
0064     }
0065 
0066     BOOST_FORCEINLINE value_type operator= (value_arg_type v) volatile BOOST_NOEXCEPT
0067     {
0068         this->store(v);
0069         return v;
0070     }
0071 
0072     BOOST_FORCEINLINE operator value_type() const volatile BOOST_NOEXCEPT
0073     {
0074         return this->load();
0075     }
0076 
0077     BOOST_DELETED_FUNCTION(ipc_atomic(ipc_atomic const&))
0078     BOOST_DELETED_FUNCTION(ipc_atomic& operator= (ipc_atomic const&))
0079     BOOST_DELETED_FUNCTION(ipc_atomic& operator= (ipc_atomic const&) volatile)
0080 };
0081 
0082 } // namespace atomics
0083 
0084 using atomics::ipc_atomic;
0085 
0086 } // namespace boost
0087 
0088 #include <boost/atomic/detail/footer.hpp>
0089 
0090 #endif // BOOST_ATOMIC_IPC_ATOMIC_HPP_INCLUDED_