From: Razvan Becheriu Date: Mon, 9 Sep 2019 09:33:50 +0000 (+0300) Subject: use std::lock_guard whenever possible X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa918a260fd41b1978005387fccbd6d578e25f91;p=thirdparty%2Fkea.git use std::lock_guard whenever possible --- diff --git a/src/lib/dhcpsrv/thread_pool.h b/src/lib/dhcpsrv/thread_pool.h index 6b73ca5537..b1b8a19c1f 100644 --- a/src/lib/dhcpsrv/thread_pool.h +++ b/src/lib/dhcpsrv/thread_pool.h @@ -44,7 +44,7 @@ struct ThreadPoolQueue { } void add(WorkItem item) { - isc::util::thread::LockGuard lock(&mutex_); + std::lock_guard lock(mutex_); if (exit_) { return; } @@ -55,7 +55,6 @@ struct ThreadPoolQueue { bool get(WorkItem& item) { std::unique_lock 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 lock(&mutex_); + std::lock_guard lock(mutex_); return queue_.size(); } void removeAll() { - isc::util::thread::LockGuard lock(&mutex_); + std::lock_guard lock(mutex_); removeAllUnsafe(); } void create() { - isc::util::thread::LockGuard lock(&mutex_); + std::lock_guard lock(mutex_); exit_ = false; } void destroy() { - isc::util::thread::LockGuard lock(&mutex_); + std::lock_guard lock(mutex_); exit_ = true; // Notify get() so that it can exit. cv_.notify_all(); diff --git a/src/lib/util/lock_guard.h b/src/lib/util/lock_guard.h index 6c949a29f6..be4eac5d4a 100644 --- a/src/lib/util/lock_guard.h +++ b/src/lib/util/lock_guard.h @@ -1,3 +1,22 @@ +// Copyright (C) 2018-2019 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2017-2019 Deutsche Telekom AG. +// +// Authors: Andrei Pavel +// Cristian Secareanu +// Razvan Becheriu +// +// 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