Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:38:12

0001 // Copyright 2019 Hans Dembinski
0002 //
0003 // Distributed under the Boost Software License, Version 1.0.
0004 // (See accompanying file LICENSE_1_0.txt
0005 // or copy at http://www.boost.org/LICENSE_1_0.txt)
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   // do not copy or move mutex
0032   mutex_base(const mutex_base&) : empty_value<DetailMutex>() {}
0033   // do not copy or move mutex
0034   mutex_base& operator=(const mutex_base&) { return *this; }
0035 };
0036 
0037 } // namespace detail
0038 } // namespace histogram
0039 } // namespace boost
0040 
0041 #endif