File indexing completed on 2025-01-18 09:38:12
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_HISTOGRAM_DETAIL_NOOP_MUTEX_HPP
0008 #define BOOST_HISTOGRAM_DETAIL_NOOP_MUTEX_HPP
0009
0010 #include <boost/core/empty_value.hpp>
0011 #include <boost/histogram/detail/axes.hpp>
0012 #include <boost/mp11/utility.hpp> // mp_if
0013 #include <mutex>
0014
0015 namespace boost {
0016 namespace histogram {
0017 namespace detail {
0018
0019 struct null_mutex {
0020 bool try_lock() noexcept { return true; }
0021 void lock() noexcept {}
0022 void unlock() noexcept {}
0023 };
0024
0025 template <class Axes, class Storage,
0026 class DetailMutex = mp11::mp_if_c<(Storage::has_threading_support &&
0027 detail::has_growing_axis<Axes>::value),
0028 std::mutex, detail::null_mutex>>
0029 struct mutex_base : empty_value<DetailMutex> {
0030 mutex_base() = default;
0031
0032 mutex_base(const mutex_base&) : empty_value<DetailMutex>() {}
0033
0034 mutex_base& operator=(const mutex_base&) { return *this; }
0035 };
0036
0037 }
0038 }
0039 }
0040
0041 #endif