mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
chore: enable -Werror=thread-safety and add missing annotations (part 2/2) (#3595)
* add missing annotations * small mutex fixes * enable -Werror=thread-safety for clang builds --------- Signed-off-by: kostas <kostas@dragonflydb.io>
This commit is contained in:
parent
0705bbb536
commit
41f7b611d0
17 changed files with 127 additions and 82 deletions
|
@ -377,6 +377,30 @@ class ABSL_LOCKABLE ThreadLocalMutex {
|
|||
util::fb2::detail::FiberInterface* locked_fiber_{nullptr};
|
||||
};
|
||||
|
||||
// Replacement of std::SharedLock that allows -Wthread-safety
|
||||
template <typename Mutex> class ABSL_SCOPED_LOCKABLE SharedLock {
|
||||
public:
|
||||
explicit SharedLock(Mutex& m) ABSL_EXCLUSIVE_LOCK_FUNCTION(m) : m_(m) {
|
||||
m_.lock_shared();
|
||||
is_locked_ = true;
|
||||
}
|
||||
|
||||
~SharedLock() ABSL_UNLOCK_FUNCTION() {
|
||||
if (is_locked_) {
|
||||
m_.unlock_shared();
|
||||
}
|
||||
}
|
||||
|
||||
void unlock() ABSL_UNLOCK_FUNCTION() {
|
||||
m_.unlock_shared();
|
||||
is_locked_ = false;
|
||||
}
|
||||
|
||||
private:
|
||||
Mutex& m_;
|
||||
bool is_locked_;
|
||||
};
|
||||
|
||||
extern size_t serialization_max_chunk_size;
|
||||
|
||||
} // namespace dfly
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue