Github user zuyu commented on a diff in the pull request:

    https://github.com/apache/incubator-quickstep/pull/232#discussion_r112417941
  
    --- Diff: cli/NetworkIO.hpp ---
    @@ -0,0 +1,227 @@
    +/**
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + **/
    +
    +#ifndef QUICKSTEP_CLI_NETWORK_IO_HPP_
    +#define QUICKSTEP_CLI_NETWORK_IO_HPP_
    +
    +#include <grpc++/grpc++.h>
    +
    +#include <iostream>
    +#include <memory>
    +#include <string>
    +#include <vector>
    +
    +#include "cli/Flags.hpp"
    +#include "cli/IOInterface.hpp"
    +#include "cli/NetworkCli.grpc.pb.h"
    +#include "cli/NetworkCli.pb.h"
    +#include "threading/ConditionVariable.hpp"
    +#include "threading/Mutex.hpp"
    +#include "utility/MemStream.hpp"
    +
    +#include "gflags/gflags.h"
    +#include "glog/logging.h"
    +
    +using grpc::Channel;
    +using grpc::ClientContext;
    +using grpc::Server;
    +using grpc::Status;
    +
    +namespace quickstep {
    +
    +namespace networkio_internal {
    +
    +/**
    + * Contains state and helper methods for managing interactions between a 
producer/consumer (requestor/requestee)
    + * thread.
    + */
    +class RequestState {
    + public:
    +  RequestState() :
    +    request_ready_(false),
    +    response_ready_(false),
    +    request_buffer_(""),
    +    mutex_(),
    +    condition_() {}
    +
    +  /**
    +   * Notifies waiter that a piece of work has been created and added to 
the buffer.
    +   * @param to_consume The arguments for the consuming thread.
    +   */
    +  void requestReady(std::string to_consume) {
    +    request_ready_ = true;
    +    response_ready_ = false;
    +    request_buffer_ = to_consume;
    +    condition_.notify_one();
    +  }
    +
    +  /**
    +   * Notifies that the consumer has finished consuming and that a response 
is ready.
    +   * To be called after the consumer has executed.
    +   */
    +  void responseReady() {
    +    request_ready_ = false;
    +    response_ready_ = true;
    +    condition_.notify_one();
    +  }
    +
    +  bool request_ready_;
    +  bool response_ready_;
    +  std::string request_buffer_;
    +  QueryResponse response_message_;
    +  std::mutex mutex_;
    +  std::condition_variable condition_;
    +};
    +}  // namespace networkio_internal
    +
    +class NetworkCliServiceImpl final : public NetworkCli::Service {
    + public:
    +  NetworkCliServiceImpl()
    +    : NetworkCli::Service(),
    +      worker_exclusive_mtx_(),
    +      running_(true),
    +      request_state_() { }
    --- End diff --
    
    No needs for `worker_exclusive_mtx_` and `request_state_`. And remove the 
whitespace in `{ }`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to