File indexing completed on 2025-01-18 09:36:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_GEOMETRY_SRS_SHARED_GRIDS_STD_HPP
0011 #define BOOST_GEOMETRY_SRS_SHARED_GRIDS_STD_HPP
0012
0013
0014 #include <boost/config.hpp>
0015
0016 #ifdef BOOST_NO_CXX14_HDR_SHARED_MUTEX
0017 #error "C++14 <shared_mutex> header required."
0018 #endif
0019
0020 #include <boost/geometry/srs/projections/grids.hpp>
0021
0022 #include <mutex>
0023 #include <shared_mutex>
0024
0025
0026 namespace boost { namespace geometry
0027 {
0028
0029 namespace srs
0030 {
0031
0032 class shared_grids_std
0033 {
0034
0035
0036 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190023918)
0037 typedef std::shared_mutex mutex_type;
0038
0039 #elif !defined(BOOST_NO_CXX14_HDR_SHARED_MUTEX) && (__cplusplus > 201402L)
0040 typedef std::shared_mutex mutex_type;
0041 #else
0042 typedef std::shared_timed_mutex mutex_type;
0043 #endif
0044
0045 public:
0046 std::size_t size() const
0047 {
0048 std::shared_lock<mutex_type> lock(mutex);
0049 return gridinfo.size();
0050 }
0051
0052 bool empty() const
0053 {
0054 std::shared_lock<mutex_type> lock(mutex);
0055 return gridinfo.empty();
0056 }
0057
0058 typedef projections::detail::shared_grids_tag tag;
0059
0060 struct read_locked
0061 {
0062 read_locked(shared_grids_std & g)
0063 : gridinfo(g.gridinfo)
0064 , lock(g.mutex)
0065 {}
0066
0067
0068 projections::detail::pj_gridinfo & gridinfo;
0069
0070 private:
0071 std::shared_lock<mutex_type> lock;
0072 };
0073
0074 struct write_locked
0075 {
0076 write_locked(shared_grids_std & g)
0077 : gridinfo(g.gridinfo)
0078 , lock(g.mutex)
0079 {}
0080
0081 projections::detail::pj_gridinfo & gridinfo;
0082
0083 private:
0084 std::unique_lock<mutex_type> lock;
0085 };
0086
0087 private:
0088 projections::detail::pj_gridinfo gridinfo;
0089 mutable mutex_type mutex;
0090 };
0091
0092
0093 }
0094
0095
0096 }}
0097
0098
0099 #endif