mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
chore: small rename and add dcheck on LocalBlockingCounter (#3356)
* add suffix _ to members * add dcheck in destructor Signed-off-by: kostas <kostas@dragonflydb.io>
This commit is contained in:
parent
2f9dc29dc6
commit
93ae2ef0e6
1 changed files with 8 additions and 8 deletions
|
@ -524,28 +524,28 @@ class DbSlice {
|
|||
|
||||
void CallChangeCallbacks(DbIndex id, const ChangeReq& cr) const;
|
||||
|
||||
private:
|
||||
class LocalBlockingCounter {
|
||||
public:
|
||||
void lock() {
|
||||
++mutating;
|
||||
++mutating_;
|
||||
}
|
||||
|
||||
void unlock() {
|
||||
--mutating;
|
||||
if (mutating == 0) {
|
||||
cond_var.notify_one();
|
||||
DCHECK(mutating_ > 0);
|
||||
--mutating_;
|
||||
if (mutating_ == 0) {
|
||||
cond_var_.notify_one();
|
||||
}
|
||||
}
|
||||
|
||||
void Wait() {
|
||||
util::fb2::NoOpLock noop_lk_;
|
||||
cond_var.wait(noop_lk_, [this]() { return mutating == 0; });
|
||||
cond_var_.wait(noop_lk_, [this]() { return mutating_ == 0; });
|
||||
}
|
||||
|
||||
private:
|
||||
util::fb2::CondVarAny cond_var;
|
||||
size_t mutating = 0;
|
||||
util::fb2::CondVarAny cond_var_;
|
||||
size_t mutating_ = 0;
|
||||
};
|
||||
|
||||
// We need this because registered callbacks might yield. If RegisterOnChange
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue