]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
use std::lock_guard whenever possible
authorRazvan Becheriu <razvan@isc.org>
Tue, 15 Oct 2019 08:29:50 +0000 (11:29 +0300)
committerRazvan Becheriu <razvan@isc.org>
Wed, 6 Nov 2019 17:30:43 +0000 (19:30 +0200)
src/bin/dhcp4/ctrl_dhcp4_srv.cc
src/bin/dhcp4/dhcp4_srv.cc
src/bin/dhcp6/ctrl_dhcp6_srv.cc
src/bin/dhcp6/dhcp6_srv.cc
src/lib/dhcp/libdhcp++.cc
src/lib/dhcpsrv/alloc_engine.h
src/lib/dhcpsrv/thread_pool.h
src/lib/dhcpsrv/thread_resource_mgr.h
src/lib/stats/stats_mgr.cc
src/lib/util/Makefile.am
src/lib/util/lock_guard.h [moved from src/lib/util/threads/lock_guard.h with 93% similarity]

index bf67cedfed704d532cfa6e955c57edf243353434..19e172b4d2c4df398b5da93c892139a52d251cb1 100644 (file)
@@ -23,7 +23,7 @@
 #include <hooks/hooks.h>
 #include <hooks/hooks_manager.h>
 #include <stats/stats_mgr.h>
-#include <util/threads/lock_guard.h>
+#include <util/lock_guard.h>
 
 #include <signal.h>
 
@@ -36,7 +36,7 @@ using namespace isc::db;
 using namespace isc::dhcp;
 using namespace isc::hooks;
 using namespace isc::stats;
-using namespace isc::util::thread;
+using namespace isc::util;
 using namespace std;
 
 namespace {
index 39903820de9695e4926afb892f63a7099b0771c0..23946d9c57238d2f3f83473d8546a55d3731b8a7 100644 (file)
@@ -45,7 +45,7 @@
 #include <hooks/hooks_manager.h>
 #include <stats/stats_mgr.h>
 #include <util/strutil.h>
-#include <util/threads/lock_guard.h>
+#include <util/lock_guard.h>
 #include <log/logger.h>
 #include <cryptolink/cryptolink.h>
 #include <cfgrpt/config_report.h>
@@ -81,7 +81,7 @@ using namespace isc::log;
 using namespace isc::stats;
 using namespace std;
 
-using isc::util::thread::LockGuard;
+using isc::util::LockGuard;
 
 namespace {
 
index f88a55dd38476600058852be5458b95a3a67756b..d405fac9ca992118af6050cfb5fed755e2e1400f 100644 (file)
@@ -23,7 +23,7 @@
 #include <hooks/hooks.h>
 #include <hooks/hooks_manager.h>
 #include <stats/stats_mgr.h>
-#include <util/threads/lock_guard.h>
+#include <util/lock_guard.h>
 
 #include <signal.h>
 
@@ -36,7 +36,7 @@ using namespace isc::db;
 using namespace isc::dhcp;
 using namespace isc::hooks;
 using namespace isc::stats;
-using namespace isc::util::thread;
+using namespace isc::util;
 using namespace std;
 
 namespace {
index 49b7d14aed1ae5d39c7f3c5a70ae19553d1c3bac..6ae81aa0a47a286a0104752ff3527bd2222a77d6 100644 (file)
@@ -49,7 +49,7 @@
 #include <util/io_utilities.h>
 #include <util/pointer_util.h>
 #include <util/range_utilities.h>
-#include <util/threads/lock_guard.h>
+#include <util/lock_guard.h>
 #include <log/logger.h>
 #include <cryptolink/cryptolink.h>
 #include <cfgrpt/config_report.h>
@@ -91,7 +91,7 @@ using namespace isc::stats;
 using namespace isc::util;
 using namespace std;
 
-using isc::util::thread::LockGuard;
+using isc::util::LockGuard;
 
 namespace {
 
index b54b229dafd7070d9a32f407311954f0838fd9e3..51de725607dbf1afe447077828f60da8d4697376 100644 (file)
@@ -19,7 +19,6 @@
 #include <dhcp/docsis3_option_defs.h>
 #include <exceptions/exceptions.h>
 #include <util/buffer.h>
-#include <util/threads/lock_guard.h>
 
 #include <boost/lexical_cast.hpp>
 #include <boost/shared_array.hpp>
@@ -90,7 +89,7 @@ void initOptionSpace(OptionDefContainerPtr& defs,
 const OptionDefContainerPtr&
 LibDHCP::getOptionDefs(const std::string& space) {
     static mutex local_mutex;
-    isc::util::thread::LockGuard<mutex> lock(&local_mutex);
+    std::lock_guard<std::mutex> lock(&local_mutex);
     // If any of the containers is not initialized, it means that we haven't
     // initialized option definitions at all.
     if (option_defs_.end() == option_defs_.find(space)) {
index 5ea6c073c9b30596867a835e8046f02940437385..32c6be7fcba67fff9b21added7e7b676b303dca5 100644 (file)
@@ -21,7 +21,6 @@
 #include <dhcpsrv/subnet.h>
 #include <dhcpsrv/lease_mgr.h>
 #include <hooks/callout_handle.h>
-#include <util/threads/lock_guard.h>
 
 #include <boost/function.hpp>
 #include <boost/shared_ptr.hpp>
@@ -96,7 +95,7 @@ protected:
                     const ClientClasses& client_classes,
                     const DuidPtr& duid,
                     const isc::asiolink::IOAddress& hint) {
-            isc::util::thread::LockGuard<std::mutex> lock(&mutex_);
+            std::lock_guard<std::mutex> lock(&mutex_);
             return pickAddressInternal(subnet, client_classes, duid, hint);
         }
 
index 6b73ca553719c0cc13635b513e59cf78becebccd..8a2ab702b4914ff205e8702e40914e3d95b005bd 100644 (file)
@@ -20,8 +20,6 @@
 #ifndef THREAD_POOL_H
 #define THREAD_POOL_H
 
-#include <util/threads/lock_guard.h>
-
 #include <boost/function.hpp>
 
 #include <atomic>
@@ -44,7 +42,7 @@ struct ThreadPoolQueue {
     }
 
     void add(WorkItem item) {
-        isc::util::thread::LockGuard<std::mutex> lock(&mutex_);
+        std::lock_guard<std::mutex> lock(&mutex_);
         if (exit_) {
             return;
         }
@@ -72,22 +70,22 @@ struct ThreadPoolQueue {
     }
 
     size_t count() {
-        isc::util::thread::LockGuard<std::mutex> lock(&mutex_);
+        std::lock_guard<std::mutex> lock(&mutex_);
         return queue_.size();
     }
 
     void removeAll() {
-        isc::util::thread::LockGuard<std::mutex> lock(&mutex_);
+        std::lock_guard<std::mutex> lock(&mutex_);
         removeAllUnsafe();
     }
 
     void create() {
-        isc::util::thread::LockGuard<std::mutex> lock(&mutex_);
+        std::lock_guard<std::mutex> lock(&mutex_);
         exit_ = false;
     }
 
     void destroy() {
-        isc::util::thread::LockGuard<std::mutex> lock(&mutex_);
+        std::lock_guard<std::mutex> lock(&mutex_);
         exit_ = true;
         // Notify get() so that it can exit.
         cv_.notify_all();
index 78011ce26935f981ad20f320e3b350f10863759e..baa2b1fea50f2f4792d03c7776c3bbea7c73b4ee 100644 (file)
@@ -7,8 +7,6 @@
 #ifndef THREAD_RESOURCE_MGR_H
 #define THREAD_RESOURCE_MGR_H
 
-#include <util/threads/lock_guard.h>
-
 #include <boost/shared_ptr.hpp>
 #include <mutex>
 #include <thread>
@@ -22,7 +20,7 @@ class ThreadResourceMgr {
     typedef boost::shared_ptr<Resource> ResourcePtr;
 public:
     ResourcePtr resource() {
-        isc::util::thread::LockGuard<std::mutex> lock(&mutex_);
+        std::lock_guard<std::mutex> lock(&mutex_);
         auto id = std::this_thread::get_id();
         if (map_.find(id) != map_.end()) {
             return map_[id];
index f4e5d4c3b958370a9a4b079947644e96465f1310..7335e2876948d0ab9a148af7bc2920bb5112ac83 100644 (file)
 #include <stats/stats_mgr.h>
 #include <cc/data.h>
 #include <cc/command_interpreter.h>
-#include <util/threads/lock_guard.h>
+#include <util/lock_guard.h>
 #include <util/boost_time_utils.h>
 #include <boost/date_time/posix_time/posix_time.hpp>
 
 using namespace std;
 using namespace isc::data;
 using namespace isc::config;
-using namespace isc::util::thread;
+using namespace isc::util;
 
 namespace isc {
 namespace stats {
index 0f0e529a17e7972ed0dc1470e7fb8c53b6764812..f26fd39f00037d08199fa34b7eb33036608ce66a 100644 (file)
@@ -14,6 +14,7 @@ libkea_util_la_SOURCES += doubles.h
 libkea_util_la_SOURCES += filename.h filename.cc
 libkea_util_la_SOURCES += hash.h
 libkea_util_la_SOURCES += labeled_value.h labeled_value.cc
+libkea_util_la_SOURCES += lock_guard.h
 libkea_util_la_SOURCES += memory_segment.h
 libkea_util_la_SOURCES += memory_segment_local.h memory_segment_local.cc
 libkea_util_la_SOURCES += multi_threading_mgr.h multi_threading_mgr.cc
similarity index 93%
rename from src/lib/util/threads/lock_guard.h
rename to src/lib/util/lock_guard.h
index 6c949a29f6ba309033b2377ffdf2b98c17c7a952..c656e035ca81f4e54aced7194f1ad396b0f76071 100644 (file)
@@ -5,7 +5,6 @@
 
 namespace isc {
 namespace util {
-namespace thread {
 
 template <typename Lock>
 class LockGuard {
@@ -32,7 +31,6 @@ private:
     Lock* lk_;
 };
 
-}  // namespace thread
 }  // namespace util
 }  // namespace isc