/* * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * * Copyright (c) 2020 Andrey Semashev */ /*! * \file atomic/ipc_atomic.hpp * * This header contains definition of \c ipc_atomic template. */ #ifndef ACTIV_BOOST_ATOMIC_IPC_ATOMIC_HPP_INCLUDED_ #define ACTIV_BOOST_ATOMIC_IPC_ATOMIC_HPP_INCLUDED_ #include #include #include #include #include #include #include #include #include #include #ifdef ACTIV_BOOST_HAS_PRAGMA_ONCE #pragma once #endif namespace Boost { namespace atomics { //! Atomic object for inter-process communication template< typename T > class ipc_atomic : public atomics::detail::base_atomic< T, typename atomics::detail::classify< T >::type, true > { private: typedef atomics::detail::base_atomic< T, typename atomics::detail::classify< T >::type, true > base_type; typedef typename base_type::value_arg_type value_arg_type; public: typedef typename base_type::value_type value_type; ACTIV_BOOST_STATIC_ASSERT_MSG(sizeof(value_type) > 0u, "Boost::ipc_atomic requires T to be a complete type"); #if !defined(ACTIV_BOOST_ATOMIC_DETAIL_NO_CXX11_IS_TRIVIALLY_COPYABLE) ACTIV_BOOST_STATIC_ASSERT_MSG(atomics::detail::is_trivially_copyable< value_type >::value, "Boost::ipc_atomic requires T to be a trivially copyable type"); #endif public: ACTIV_BOOST_FORCEINLINE ACTIV_BOOST_ATOMIC_DETAIL_CONSTEXPR_UNION_INIT ipc_atomic() ACTIV_BOOST_NOEXCEPT_IF(atomics::detail::is_nothrow_default_constructible< value_type >::value) : base_type() { } ACTIV_BOOST_FORCEINLINE ACTIV_BOOST_ATOMIC_DETAIL_CONSTEXPR_UNION_INIT ipc_atomic(value_arg_type v) ACTIV_BOOST_NOEXCEPT : base_type(v) { } ACTIV_BOOST_FORCEINLINE value_type operator= (value_arg_type v) ACTIV_BOOST_NOEXCEPT { this->store(v); return v; } ACTIV_BOOST_FORCEINLINE value_type operator= (value_arg_type v) volatile ACTIV_BOOST_NOEXCEPT { this->store(v); return v; } ACTIV_BOOST_FORCEINLINE operator value_type() const volatile ACTIV_BOOST_NOEXCEPT { return this->load(); } ACTIV_BOOST_DELETED_FUNCTION(ipc_atomic(ipc_atomic const&)) ACTIV_BOOST_DELETED_FUNCTION(ipc_atomic& operator= (ipc_atomic const&)) ACTIV_BOOST_DELETED_FUNCTION(ipc_atomic& operator= (ipc_atomic const&) volatile) }; } // namespace atomics using atomics::ipc_atomic; } // namespace Boost #include #endif // ACTIV_BOOST_ATOMIC_IPC_ATOMIC_HPP_INCLUDED_