feat: DispatchTracker to replace everything (#2179)

* feat: DispatchTracker

Use a DispatchTracker to track ongoing dispatches for commands that change global state

---------

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
This commit is contained in:
Vladislav 2023-12-05 11:02:11 +03:00 committed by GitHub
parent f39eac5bca
commit 11ef6623dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 165 additions and 143 deletions

View file

@ -121,30 +121,13 @@ void ServerState::SetPauseState(ClientPause state, bool start) {
void ServerState::AwaitPauseState(bool is_write) {
client_pause_ec_.await([is_write, this]() {
if (client_pauses_[int(ClientPause::ALL)]) {
return false;
}
if (is_write && client_pauses_[int(ClientPause::WRITE)]) {
return false;
}
return true;
return client_pauses_[int(ClientPause::ALL)] == 0 &&
(!is_write || client_pauses_[int(ClientPause::WRITE)] == 0);
});
}
void ServerState::AwaitOnPauseDispatch() {
pause_dispatch_ec_.await([this]() {
if (pause_dispatch_) {
return false;
}
return true;
});
}
void ServerState::SetPauseDispatch(bool pause) {
pause_dispatch_ = pause;
if (!pause_dispatch_) {
pause_dispatch_ec_.notifyAll();
}
bool ServerState::IsPaused() const {
return (client_pauses_[0] + client_pauses_[1]) > 0;
}
Interpreter* ServerState::BorrowInterpreter() {