]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
use std::lock_guard whenever possible
authorRazvan Becheriu <razvan@isc.org>
Mon, 9 Sep 2019 09:33:50 +0000 (12:33 +0300)
committerRazvan Becheriu <razvan@isc.org>
Fri, 8 Nov 2019 13:52:29 +0000 (15:52 +0200)
src/lib/dhcpsrv/thread_pool.h
src/lib/util/lock_guard.h

index 6b73ca553719c0cc13635b513e59cf78becebccd..b1b8a19c1f4afd3437542557c2718aa9f6af5699 100644 (file)
@@ -44,7 +44,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;
         }
@@ -55,7 +55,6 @@ struct ThreadPoolQueue {
 
     bool get(WorkItem& item) {
         std::unique_lock<std::mutex> lock(mutex_);
-
         while (!exit_) {
             if (queue_.empty()) {
                 // Wait for add() or destroy().
@@ -72,22 +71,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 6c949a29f6ba309033b2377ffdf2b98c17c7a952..be4eac5d4a86005b0f6baf5bb039bc6acca22ee7 100644 (file)
@@ -1,3 +1,22 @@
+// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2017-2019 Deutsche Telekom AG.
+//
+// Authors: Andrei Pavel <andrei.pavel@qualitance.com>
+//          Cristian Secareanu <cristian.secareanu@qualitance.com>
+//          Razvan Becheriu <razvan.becheriu@qualitance.com>
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//           http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
 #ifndef LOCK_GUARD_H
 #define LOCK_GUARD_H