From ab1dba72dc66ff63ca56286e3d154951fba6e41e Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Fri, 31 Jul 2015 09:09:09 -0700 Subject: [PATCH] clang-format --- test/cpp/qps/client.h | 46 ++++++++++++++++++++---------------- test/cpp/qps/client_async.cc | 45 ++++++++++++++++++----------------- test/cpp/qps/interarrival.h | 4 ++-- 3 files changed, 50 insertions(+), 45 deletions(-) diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 5cd99950d83..cdcae9ad3fb 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -71,7 +71,8 @@ class Client { explicit Client(const ClientConfig& config) : timer_(new Timer), interarrival_timer_() { for (int i = 0; i < config.client_channels(); i++) { - channels_.emplace_back(config.server_targets(i % config.server_targets_size()), config); + channels_.emplace_back( + config.server_targets(i % config.server_targets_size()), config); } request_.set_response_type(grpc::testing::PayloadType::COMPRESSABLE); request_.set_response_size(config.payload_size()); @@ -188,8 +189,11 @@ class Client { class Thread { public: Thread(Client* client, size_t idx) - : done_(false), new_(nullptr), client_(client), idx_(idx), - impl_(&Thread::ThreadFunc, this) {} + : done_(false), + new_(nullptr), + client_(client), + idx_(idx), + impl_(&Thread::ThreadFunc, this) {} ~Thread() { { @@ -215,23 +219,23 @@ class Client { void ThreadFunc() { for (;;) { - // run the loop body - bool thread_still_ok = client_->ThreadFunc(&histogram_, idx_); - // lock, see if we're done - std::lock_guard g(mu_); - if (!thread_still_ok) { - gpr_log(GPR_ERROR, "Finishing client thread due to RPC error"); - done_ = true; - } - if (done_) { - return; - } - // check if we're marking, swap out the histogram if so - if (new_) { - new_->Swap(&histogram_); - new_ = nullptr; - cv_.notify_one(); - } + // run the loop body + bool thread_still_ok = client_->ThreadFunc(&histogram_, idx_); + // lock, see if we're done + std::lock_guard g(mu_); + if (!thread_still_ok) { + gpr_log(GPR_ERROR, "Finishing client thread due to RPC error"); + done_ = true; + } + if (done_) { + return; + } + // check if we're marking, swap out the histogram if so + if (new_) { + new_->Swap(&histogram_); + new_ = nullptr; + cv_.notify_one(); + } } } @@ -242,7 +246,7 @@ class Client { bool done_; Histogram* new_; Histogram histogram_; - Client *client_; + Client* client_; size_t idx_; std::thread impl_; }; diff --git a/test/cpp/qps/client_async.cc b/test/cpp/qps/client_async.cc index f517f1ae237..55f07f78f39 100644 --- a/test/cpp/qps/client_async.cc +++ b/test/cpp/qps/client_async.cc @@ -316,21 +316,25 @@ class AsyncClient : public Client { } private: - class boolean { // exists only to avoid data-race on vector + class boolean { // exists only to avoid data-race on vector public: - boolean(): val_(false) {} - boolean(bool b): val_(b) {} - operator bool() const {return val_;} - boolean& operator=(bool b) {val_=b; return *this;} + boolean() : val_(false) {} + boolean(bool b) : val_(b) {} + operator bool() const { return val_; } + boolean& operator=(bool b) { + val_ = b; + return *this; + } + private: bool val_; }; std::vector> cli_cqs_; std::vector rpc_deadlines_; // per thread deadlines - std::vector next_channel_; // per thread round-robin channel ctr - std::vector issue_allowed_; // may this thread attempt to issue - std::vector next_issue_; // when should it issue? + std::vector next_channel_; // per thread round-robin channel ctr + std::vector issue_allowed_; // may this thread attempt to issue + std::vector next_issue_; // when should it issue? std::vector channel_lock_; std::vector contexts_; // per-channel list of idle contexts @@ -350,17 +354,15 @@ class AsyncUnaryClient GRPC_FINAL : public AsyncClient { private: static void CheckDone(grpc::Status s, SimpleResponse* response) {} static std::unique_ptr> - StartReq(TestService::Stub* stub, grpc::ClientContext* ctx, - const SimpleRequest& request, CompletionQueue* cq) { + StartReq(TestService::Stub* stub, grpc::ClientContext* ctx, + const SimpleRequest& request, CompletionQueue* cq) { return stub->AsyncUnaryCall(ctx, request, cq); }; static ClientRpcContext* SetupCtx(int channel_id, TestService::Stub* stub, const SimpleRequest& req) { - return new - ClientRpcContextUnaryImpl(channel_id, stub, req, - AsyncUnaryClient::StartReq, - AsyncUnaryClient::CheckDone); + return new ClientRpcContextUnaryImpl( + channel_id, stub, req, AsyncUnaryClient::StartReq, + AsyncUnaryClient::CheckDone); } }; @@ -447,19 +449,18 @@ class AsyncStreamingClient GRPC_FINAL : public AsyncClient { private: static void CheckDone(grpc::Status s, SimpleResponse* response) {} - static std::unique_ptr> - StartReq(TestService::Stub* stub, grpc::ClientContext* ctx, - CompletionQueue* cq, void* tag) { + static std::unique_ptr< + grpc::ClientAsyncReaderWriter> + StartReq(TestService::Stub* stub, grpc::ClientContext* ctx, + CompletionQueue* cq, void* tag) { auto stream = stub->AsyncStreamingCall(ctx, cq, tag); return stream; }; static ClientRpcContext* SetupCtx(int channel_id, TestService::Stub* stub, const SimpleRequest& req) { return new ClientRpcContextStreamingImpl( - channel_id, stub, req, - AsyncStreamingClient::StartReq, - AsyncStreamingClient::CheckDone); + channel_id, stub, req, AsyncStreamingClient::StartReq, + AsyncStreamingClient::CheckDone); } }; diff --git a/test/cpp/qps/interarrival.h b/test/cpp/qps/interarrival.h index a4fecb7bab0..da16a1553ff 100644 --- a/test/cpp/qps/interarrival.h +++ b/test/cpp/qps/interarrival.h @@ -150,8 +150,8 @@ class InterarrivalTimer { // rand is the only choice that is portable across POSIX and Windows // and that supports new and old compilers double uniform_0_1 = rand() / RAND_MAX; - random_table_.push_back(std::chrono::nanoseconds( - static_cast(1e9 * r(uniform_0_1)))); + random_table_.push_back( + std::chrono::nanoseconds(static_cast(1e9 * r(uniform_0_1)))); } // Now set up the thread positions for (int i = 0; i < threads; i++) {