HDFS-10739: libhdfs++: In RpcEngine replace vector with deque for pending requests. Contributed by Anatoli Shein.

This commit is contained in:
James 2016-08-09 15:55:18 -04:00 committed by James Clampffer
parent 649aff11fe
commit b1ed72e098
2 changed files with 3 additions and 3 deletions

View File

@ -445,7 +445,6 @@ void RpcConnection::SendRpcRequests(const std::vector<std::shared_ptr<Request> >
Status status = Status::ResourceUnavailable("RpcConnection closed before send.");
engine_->AsyncRpcCommsError(status, shared_from_this(), requests);
} else {
pending_requests_.reserve(pending_requests_.size() + requests.size());
for (auto r: requests) {
if (r->method_name() != SASL_METHOD_NAME)
pending_requests_.push_back(r);

View File

@ -41,6 +41,7 @@
#include <memory>
#include <unordered_map>
#include <vector>
#include <deque>
#include <mutex>
#include <future>
@ -234,10 +235,10 @@ class RpcConnection : public std::enable_shared_from_this<RpcConnection> {
// The request being sent over the wire; will also be in requests_on_fly_
std::shared_ptr<Request> request_over_the_wire_;
// Requests to be sent over the wire
std::vector<std::shared_ptr<Request>> pending_requests_;
std::deque<std::shared_ptr<Request>> pending_requests_;
// Requests to be sent over the wire during authentication; not retried if
// there is a connection error
std::vector<std::shared_ptr<Request>> auth_requests_;
std::deque<std::shared_ptr<Request>> auth_requests_;
// Requests that are waiting for responses
typedef std::unordered_map<int, std::shared_ptr<Request>> RequestOnFlyMap;
RequestOnFlyMap requests_on_fly_;