Skip to content

Commit 2c7452e

Browse files
committed
HashBucketLock: Fix defaulted-function-deleted warning
As reported by clang 8, the move assigment operator of StoredValueProxy is implicitly deleted because one of it's members (of type HashBucketLock) does _not_ have a move assignment operator itself: kv_engine/engines/ep/src/hash_table.h:682:27: warning: explicitly defaulted move assignment operator is implicitly deleted [-Wdefaulted-function-deleted] StoredValueProxy& operator=(StoredValueProxy&&) = default; ^ kv_engine/engines/ep/src/hash_table.h:720:24: note: move assignment operator of 'StoredValueProxy' is implicitly deleted because field 'lock' has a deleted move assignment operator HashBucketLock lock; ^ kv_engine/engines/ep/src/hash_table.h:397:9: note: copy assignment operator is implicitly deleted because 'HashBucketLock' has a user-declared move constructor HashBucketLock(HashBucketLock&& other) ^ There's also a further problem with `valueStats` as that is a reference which also cannot be used. Fix by defining a move-assignment operator for HashBucketLock, and use a reference_wrapper for `valueStats`. Change-Id: Ib2e2b6617d31ca3bb70666ec01338516da0ffb71 Reviewed-on: http://review.couchbase.org/110144 Tested-by: Build Bot <[email protected]> Reviewed-by: Ben Huddleston <[email protected]>
1 parent c0baa02 commit 2c7452e

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

engines/ep/src/hash_table.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,11 @@ HashTable::StoredValueProxy::StoredValueProxy(HashBucketLock&& hbl,
9292
: lock(std::move(hbl)),
9393
value(sv),
9494
valueStats(stats),
95-
pre(valueStats.prologue(sv)) {
95+
pre(valueStats.get().prologue(sv)) {
9696
}
9797

9898
HashTable::StoredValueProxy::~StoredValueProxy() {
99-
valueStats.epilogue(pre, value);
99+
valueStats.get().epilogue(pre, value);
100100
}
101101

102102
void HashTable::StoredValueProxy::setCommitted(CommittedState state) {

engines/ep/src/hash_table.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,15 @@ class HashTable {
398398
: bucketNum(other.bucketNum), htLock(std::move(other.htLock)) {
399399
}
400400

401+
// Cannot copy HashBucketLock.
401402
HashBucketLock(const HashBucketLock& other) = delete;
403+
HashBucketLock& operator=(const HashBucketLock& other) = delete;
404+
405+
HashBucketLock& operator=(HashBucketLock&& other) {
406+
bucketNum = other.bucketNum;
407+
htLock = std::move(other.htLock);
408+
return *this;
409+
}
402410

403411
int getBucketNum() const {
404412
return bucketNum;
@@ -719,7 +727,8 @@ class HashTable {
719727
private:
720728
HashBucketLock lock;
721729
StoredValue* value;
722-
Statistics& valueStats;
730+
// Using ref wrapper to support move.
731+
std::reference_wrapper<Statistics> valueStats;
723732
Statistics::StoredValueProperties pre;
724733
};
725734

0 commit comments

Comments
 (0)