3 // Copyright (c) 2018-2019, Oracle and/or its affiliates.
4 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_GEOMETRY_SRS_SHARED_GRIDS_STD_HPP
11 #define BOOST_GEOMETRY_SRS_SHARED_GRIDS_STD_HPP
14 #include <boost/config.hpp>
16 #ifdef BOOST_NO_CXX14_HDR_SHARED_MUTEX
17 #error "C++14 <shared_mutex> header required."
20 #include <boost/geometry/srs/projections/grids.hpp>
23 #include <shared_mutex>
26 namespace boost { namespace geometry
32 class shared_grids_std
36 #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190023918)
37 typedef std::shared_mutex mutex_type;
39 #elif !defined(BOOST_NO_CXX14_HDR_SHARED_MUTEX) && (__cplusplus > 201402L)
40 typedef std::shared_mutex mutex_type;
42 typedef std::shared_timed_mutex mutex_type;
46 std::size_t size() const
48 std::shared_lock<mutex_type> lock(mutex);
49 return gridinfo.size();
54 std::shared_lock<mutex_type> lock(mutex);
55 return gridinfo.empty();
58 typedef projections::detail::shared_grids_tag tag;
62 read_locked(shared_grids_std & g)
63 : gridinfo(g.gridinfo)
68 projections::detail::pj_gridinfo & gridinfo;
71 std::shared_lock<mutex_type> lock;
76 write_locked(shared_grids_std & g)
77 : gridinfo(g.gridinfo)
81 projections::detail::pj_gridinfo & gridinfo;
84 std::unique_lock<mutex_type> lock;
88 projections::detail::pj_gridinfo gridinfo;
89 mutable mutex_type mutex;
96 }} // namespace boost::geometry
99 #endif // BOOST_GEOMETRY_SRS_SHARED_GRIDS_STD_HPP