PragmaTwice commented on code in PR #3047:
URL: https://github.com/apache/kvrocks/pull/3047#discussion_r2191746306
##########
src/server/server.cc:
##########
@@ -700,6 +701,76 @@ void Server::OnEntryAddedToStream(const std::string &ns,
const std::string &key,
}
}
+void Server::BlockOnWait(redis::Connection *conn, rocksdb::SequenceNumber
target_seq, int num_replicas) {
+ std::lock_guard<std::mutex> guard(wait_contexts_mu_);
+
+ wait_contexts_.emplace_back(conn, target_seq, num_replicas);
+ IncrBlockedClientNum();
+}
+
+void Server::UnblockOnWait(redis::Connection *conn) {
+ std::lock_guard<std::mutex> guard(wait_contexts_mu_);
+
+ for (auto it = wait_contexts_.begin(); it != wait_contexts_.end(); ++it) {
+ if (it->conn == conn) {
+ wait_contexts_.erase(it);
+ DecrBlockedClientNum();
+ break;
+ }
+ }
Review Comment:
Maybe it can be replaced by something like `std::find_if`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]