]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/srs/shared_grids_boost.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / srs / shared_grids_boost.hpp
1 // Boost.Geometry
2
3 // Copyright (c) 2018-2019, Oracle and/or its affiliates.
4 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
5
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)
9
10 #ifndef BOOST_GEOMETRY_SRS_SHARED_GRIDS_BOOST_HPP
11 #define BOOST_GEOMETRY_SRS_SHARED_GRIDS_BOOST_HPP
12
13
14 #include <boost/geometry/srs/projections/grids.hpp>
15
16
17 #include <boost/thread.hpp>
18
19
20 namespace boost { namespace geometry
21 {
22
23 namespace srs
24 {
25
26 class shared_grids_boost
27 {
28 public:
29 std::size_t size() const
30 {
31 boost::shared_lock<boost::shared_mutex> lock(mutex);
32 return gridinfo.size();
33 }
34
35 bool empty() const
36 {
37 boost::shared_lock<boost::shared_mutex> lock(mutex);
38 return gridinfo.empty();
39 }
40
41 typedef projections::detail::shared_grids_tag tag;
42
43 struct read_locked
44 {
45 read_locked(shared_grids_boost & g)
46 : gridinfo(g.gridinfo)
47 , lock(g.mutex)
48 {}
49
50 // should be const&
51 projections::detail::pj_gridinfo & gridinfo;
52
53 private:
54 boost::shared_lock<boost::shared_mutex> lock;
55 };
56
57 struct write_locked
58 {
59 write_locked(shared_grids_boost & g)
60 : gridinfo(g.gridinfo)
61 , lock(g.mutex)
62 {}
63
64 projections::detail::pj_gridinfo & gridinfo;
65
66 private:
67 boost::unique_lock<boost::shared_mutex> lock;
68 };
69
70 private:
71 projections::detail::pj_gridinfo gridinfo;
72 mutable boost::shared_mutex mutex;
73 };
74
75
76 } // namespace srs
77
78
79 }} // namespace boost::geometry
80
81
82 #endif // BOOST_GEOMETRY_SRS_SHARED_GRIDS_BOOST_HPP