mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 02:15:45 +02:00
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:
parent
f39eac5bca
commit
11ef6623dc
17 changed files with 165 additions and 143 deletions
|
@ -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() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue