summaryrefslogtreecommitdiffstats
path: root/src/lib/util
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2022-10-07 14:51:42 +0200
committerAndrei Pavel <andrei@isc.org>2022-10-21 16:45:24 +0200
commit79989560796acd88d4b4c19c955ad75a673e9541 (patch)
tree944109218687b95637124cfc3c46afa418fdf811 /src/lib/util
parent[#2311] fix variable shadowing (diff)
downloadkea-79989560796acd88d4b4c19c955ad75a673e9541.tar.xz
kea-79989560796acd88d4b4c19c955ad75a673e9541.zip
[#2311] fix deprecated capture of 'this' in C++20
In file included from readwrite_mutex_unittest.cc:9: ../../../../src/lib/util/readwrite_mutex.h: In lambda function: ../../../../src/lib/util/readwrite_mutex.h:57:25: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated] 57 | gate1_.wait(lk, [=]() { return (!writeEntered()); }); | ^ ../../../../src/lib/util/readwrite_mutex.h:57:25: note: add explicit ‘this’ or ‘*this’ capture ../../../../src/lib/util/readwrite_mutex.h: In lambda function: ../../../../src/lib/util/readwrite_mutex.h:60:25: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated] 60 | gate2_.wait(lk, [=]() { return (readers() == 0); }); | ^ ../../../../src/lib/util/readwrite_mutex.h:60:25: note: add explicit ‘this’ or ‘*this’ capture ../../../../src/lib/util/readwrite_mutex.h: In lambda function: ../../../../src/lib/util/readwrite_mutex.h:77:25: warning: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20 [-Wdeprecated] 77 | gate1_.wait(lk, [=]() { return (state_ < MAX_READERS); }); | ^ ../../../../src/lib/util/readwrite_mutex.h:77:25: note: add explicit ‘this’ or ‘*this’ capture
Diffstat (limited to 'src/lib/util')
-rw-r--r--src/lib/util/readwrite_mutex.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/util/readwrite_mutex.h b/src/lib/util/readwrite_mutex.h
index f8766d5af4..4a6ecfe3fa 100644
--- a/src/lib/util/readwrite_mutex.h
+++ b/src/lib/util/readwrite_mutex.h
@@ -54,10 +54,10 @@ public:
void writeLock() {
std::unique_lock<std::mutex> lk(mutex_);
// Wait until the write entered flag can be set.
- gate1_.wait(lk, [=]() { return (!writeEntered()); });
+ gate1_.wait(lk, [=, this]() { return (!writeEntered()); });
state_ |= WRITE_ENTERED;
// Wait until there are no more readers.
- gate2_.wait(lk, [=]() { return (readers() == 0); });
+ gate2_.wait(lk, [=, this]() { return (readers() == 0); });
}
/// @brief Unlock write.
@@ -74,7 +74,7 @@ public:
void readLock() {
std::unique_lock<std::mutex> lk(mutex_);
// Wait if there is a writer or if readers overflow.
- gate1_.wait(lk, [=]() { return (state_ < MAX_READERS); });
+ gate1_.wait(lk, [=, this]() { return (state_ < MAX_READERS); });
++state_;
}