1// atomic_tools.hpp ------------------------------------------------------------------//
2
3// Copyright 2021 Andrey Semashev
4
5// Distributed under the Boost Software License, Version 1.0.
6// See http://www.boost.org/LICENSE_1_0.txt
7
8// See library home page at http://www.boost.org/libs/filesystem
9
10//--------------------------------------------------------------------------------------//
11
12#ifndef BOOST_FILESYSTEM_SRC_ATOMIC_TOOLS_HPP_
13#define BOOST_FILESYSTEM_SRC_ATOMIC_TOOLS_HPP_
14
15#include <boost/filesystem/config.hpp>
16
17#if !defined(BOOST_FILESYSTEM_SINGLE_THREADED)
18
19#include "atomic_ref.hpp"
20
21namespace boost {
22namespace filesystem {
23namespace detail {
24
25//! Atomically loads the value
26template< typename T >
27BOOST_FORCEINLINE T atomic_load_relaxed(T& a)
28{
29 return atomic_ns::atomic_ref< T >(a).load(atomic_ns::memory_order_relaxed);
30}
31
32//! Atomically stores the value
33template< typename T >
34BOOST_FORCEINLINE void atomic_store_relaxed(T& a, T val)
35{
36 atomic_ns::atomic_ref< T >(a).store(val, atomic_ns::memory_order_relaxed);
37}
38
39} // namespace detail
40} // namespace filesystem
41} // namespace boost
42
43#else // !defined(BOOST_FILESYSTEM_SINGLE_THREADED)
44
45namespace boost {
46namespace filesystem {
47namespace detail {
48
49//! Atomically loads the value
50template< typename T >
51BOOST_FORCEINLINE T atomic_load_relaxed(T const& a)
52{
53 return a;
54}
55
56//! Atomically stores the value
57template< typename T >
58BOOST_FORCEINLINE void atomic_store_relaxed(T& a, T val)
59{
60 a = val;
61}
62
63} // namespace detail
64} // namespace filesystem
65} // namespace boost
66
67#endif // !defined(BOOST_FILESYSTEM_SINGLE_THREADED)
68
69#endif // BOOST_FILESYSTEM_SRC_ATOMIC_TOOLS_HPP_
70

source code of boost/libs/filesystem/src/atomic_tools.hpp