diff --git a/include/mapnik/debug.hpp b/include/mapnik/debug.hpp index 4e9609d90..a00bca619 100644 --- a/include/mapnik/debug.hpp +++ b/include/mapnik/debug.hpp @@ -25,7 +25,6 @@ // mapnik (should not depend on anything that need to use this) #include -#include #include #include @@ -70,7 +69,7 @@ namespace mapnik { static void set_severity(severity_type const& severity_level) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(severity_mutex_); + std::lock_guard lock(severity_mutex_); #endif severity_level_ = severity_level; @@ -94,7 +93,7 @@ namespace mapnik { severity_type const& security_level) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(severity_mutex_); + std::lock_guard lock(severity_mutex_); #endif if (! object_name.empty()) { @@ -105,7 +104,7 @@ namespace mapnik { static void clear_object_severity() { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(severity_mutex_); + std::lock_guard lock(severity_mutex_); #endif object_severity_level_.clear(); @@ -120,7 +119,7 @@ namespace mapnik { static void set_format(std::string const& format) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(format_mutex_); + std::lock_guard lock(format_mutex_); #endif format_ = format; } @@ -166,7 +165,7 @@ namespace mapnik { { #ifdef MAPNIK_THREADSAFE static std::mutex mutex; - mapnik::scoped_lock lock(mutex); + std::lock_guard lock(mutex); #endif std::clog << logger::str() << " " << s.str() << std::endl; } diff --git a/include/mapnik/pool.hpp b/include/mapnik/pool.hpp index 87580b262..59e8661d3 100644 --- a/include/mapnik/pool.hpp +++ b/include/mapnik/pool.hpp @@ -24,7 +24,6 @@ #define MAPNIK_POOL_HPP // mapnik -#include #include #include @@ -71,7 +70,7 @@ public: HolderType borrowObject() { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif typename ContType::iterator itr=pool_.begin(); @@ -106,7 +105,7 @@ public: unsigned size() const { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif return pool_.size(); } @@ -114,7 +113,7 @@ public: unsigned max_size() const { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif return maxSize_; } @@ -122,7 +121,7 @@ public: void set_max_size(unsigned size) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif maxSize_ = std::max(maxSize_,size); } @@ -130,7 +129,7 @@ public: unsigned initial_size() const { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif return initialSize_; } @@ -138,7 +137,7 @@ public: void set_initial_size(unsigned size) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif if (size > initialSize_) { diff --git a/include/mapnik/unique_lock.hpp b/include/mapnik/unique_lock.hpp deleted file mode 100644 index 58d113c35..000000000 --- a/include/mapnik/unique_lock.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2014 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -#ifndef MAPNIK_UNIQUE_LOCK_HPP -#define MAPNIK_UNIQUE_LOCK_HPP - -#include - -namespace mapnik -{ - using scoped_lock = std::unique_lock; -} - -#endif // MAPNIK_UNIQUE_LOCK_HPP diff --git a/include/mapnik/utils.hpp b/include/mapnik/utils.hpp index c43bebf37..a306f1c6c 100644 --- a/include/mapnik/utils.hpp +++ b/include/mapnik/utils.hpp @@ -24,7 +24,6 @@ #define MAPNIK_UTILS_HPP #include -#include // stl #include // std::runtime_error @@ -123,7 +122,7 @@ protected: if (! pInstance_) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif if (! pInstance_) { diff --git a/src/datasource_cache.cpp b/src/datasource_cache.cpp index 946a03d6f..97d65508f 100644 --- a/src/datasource_cache.cpp +++ b/src/datasource_cache.cpp @@ -89,7 +89,7 @@ datasource_ptr datasource_cache::create(parameters const& params) // add scope to ensure lock is released asap { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif itr=plugins_.find(*type); if (itr == plugins_.end()) @@ -156,7 +156,7 @@ std::vector datasource_cache::plugin_names() bool datasource_cache::register_datasources(std::string const& dir, bool recurse) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif if (!mapnik::util::exists(dir)) { diff --git a/src/font_engine_freetype.cpp b/src/font_engine_freetype.cpp index 412b59511..1c87f87c1 100644 --- a/src/font_engine_freetype.cpp +++ b/src/font_engine_freetype.cpp @@ -84,7 +84,7 @@ unsigned long ft_read_cb(FT_Stream stream, unsigned long offset, unsigned char * bool freetype_engine::register_font(std::string const& file_name) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif font_library library; return register_font_impl(file_name, library, global_font_file_mapping_); @@ -166,7 +166,7 @@ bool freetype_engine::register_font_impl(std::string const& file_name, bool freetype_engine::register_fonts(std::string const& dir, bool recurse) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif font_library library; return register_fonts_impl(dir, library, global_font_file_mapping_, recurse); @@ -338,7 +338,7 @@ face_ptr freetype_engine::create_face(std::string const& family_name, if (file.open()) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif auto result = global_memory_fonts.emplace(itr->second.second, std::make_pair(std::move(file.data()),file.size())); FT_Face face; diff --git a/src/mapped_memory_cache.cpp b/src/mapped_memory_cache.cpp index f296c2253..c589681e8 100644 --- a/src/mapped_memory_cache.cpp +++ b/src/mapped_memory_cache.cpp @@ -38,7 +38,7 @@ namespace mapnik void mapped_memory_cache::clear() { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif return cache_.clear(); } @@ -46,7 +46,7 @@ void mapped_memory_cache::clear() bool mapped_memory_cache::insert(std::string const& uri, mapped_region_ptr mem) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif return cache_.emplace(uri,mem).second; } @@ -54,7 +54,7 @@ bool mapped_memory_cache::insert(std::string const& uri, mapped_region_ptr mem) boost::optional mapped_memory_cache::find(std::string const& uri, bool update_cache) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif using iterator_type = std::unordered_map::const_iterator; boost::optional result; diff --git a/src/marker_cache.cpp b/src/marker_cache.cpp index c59a6f705..e0fe08d0d 100644 --- a/src/marker_cache.cpp +++ b/src/marker_cache.cpp @@ -70,7 +70,7 @@ marker_cache::~marker_cache() {} void marker_cache::clear() { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif using iterator_type = boost::unordered_map >::const_iterator; iterator_type itr = marker_cache_.begin(); @@ -112,7 +112,7 @@ bool marker_cache::insert_svg(std::string const& name, std::string const& svg_st bool marker_cache::insert_marker(std::string const& uri, mapnik::marker && path) { #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif return marker_cache_.emplace(uri,std::make_shared(std::move(path))).second; } @@ -137,7 +137,7 @@ struct visitor_create_marker marker operator() (T & data) { throw std::runtime_error("Can not make marker from this data type"); - } + } }; } // end detail ns @@ -151,7 +151,7 @@ std::shared_ptr marker_cache::find(std::string const& uri, } #ifdef MAPNIK_THREADSAFE - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif using iterator_type = boost::unordered_map >::const_iterator; iterator_type itr = marker_cache_.find(uri); diff --git a/src/projection.cpp b/src/projection.cpp index 44c56eb0c..81e24277f 100644 --- a/src/projection.cpp +++ b/src/projection.cpp @@ -120,7 +120,7 @@ void projection::init_proj4() const } #else #if defined(MAPNIK_THREADSAFE) - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif proj_ = pj_init_plus(params_.c_str()); if (!proj_) throw proj_init_error(params_); @@ -158,7 +158,7 @@ void projection::forward(double & x, double &y ) const throw std::runtime_error("projection::forward not supported unless proj4 is initialized"); } #if defined(MAPNIK_THREADSAFE) && PJ_VERSION < 480 - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif projUV p; p.u = x * DEG_TO_RAD; @@ -185,7 +185,7 @@ void projection::inverse(double & x,double & y) const } #if defined(MAPNIK_THREADSAFE) && PJ_VERSION < 480 - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif if (is_geographic_) { @@ -207,7 +207,7 @@ projection::~projection() { #ifdef MAPNIK_USE_PROJ4 #if defined(MAPNIK_THREADSAFE) && PJ_VERSION < 480 - mapnik::scoped_lock lock(mutex_); + std::lock_guard lock(mutex_); #endif if (proj_) {