aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/restricted/boost/filesystem/src/atomic_tools.hpp
blob: a60e5d325aa92e75f4897ce6d1065b75ef16eca0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//  atomic_tools.hpp  ------------------------------------------------------------------//

//  Copyright 2021 Andrey Semashev

//  Distributed under the Boost Software License, Version 1.0.
//  See http://www.boost.org/LICENSE_1_0.txt

//  See library home page at http://www.boost.org/libs/filesystem

//--------------------------------------------------------------------------------------//

#ifndef BOOST_FILESYSTEM_SRC_ATOMIC_TOOLS_HPP_
#define BOOST_FILESYSTEM_SRC_ATOMIC_TOOLS_HPP_

#include <boost/filesystem/config.hpp>

#if !defined(BOOST_FILESYSTEM_SINGLE_THREADED)

#include "atomic_ref.hpp"

namespace boost {
namespace filesystem {
namespace detail {

//! Atomically loads the value
template< typename T >
BOOST_FORCEINLINE T atomic_load_relaxed(T& a)
{
    return atomic_ns::atomic_ref< T >(a).load(atomic_ns::memory_order_relaxed);
}

//! Atomically stores the value
template< typename T >
BOOST_FORCEINLINE void atomic_store_relaxed(T& a, T val)
{
    atomic_ns::atomic_ref< T >(a).store(val, atomic_ns::memory_order_relaxed);
}

} // namespace detail
} // namespace filesystem
} // namespace boost

#else // !defined(BOOST_FILESYSTEM_SINGLE_THREADED)

namespace boost {
namespace filesystem {
namespace detail {

//! Atomically loads the value
template< typename T >
BOOST_FORCEINLINE T atomic_load_relaxed(T const& a)
{
    return a;
}

//! Atomically stores the value
template< typename T >
BOOST_FORCEINLINE void atomic_store_relaxed(T& a, T val)
{
    a = val;
}

} // namespace detail
} // namespace filesystem
} // namespace boost

#endif // !defined(BOOST_FILESYSTEM_SINGLE_THREADED)

#endif // BOOST_FILESYSTEM_SRC_ATOMIC_TOOLS_HPP_