Merge branch 'c++api' of github.com:ctiller/grpc into c++api

pull/501/head
Yang Gao 10 years ago
commit a5e2a03fec
  1. 13
      include/grpc++/server_context.h
  2. 2
      src/cpp/common/completion_queue.cc
  3. 14
      src/cpp/server/server_context.cc

@ -35,7 +35,7 @@
#define __GRPCPP_SERVER_CONTEXT_H_
#include <chrono>
#include <vector>
#include <map>
#include "config.h"
@ -44,16 +44,21 @@ struct gpr_timespec;
namespace grpc {
class Server;
// Interface of server side rpc context.
class ServerContext {
public:
ServerContext(gpr_timespec deadline, grpc_metadata *metadata, size_t metadata_count);
virtual ~ServerContext() {}
std::chrono::system_clock::time_point absolute_deadline();
std::chrono::system_clock::time_point absolute_deadline() { return deadline_; }
private:
std::vector<std::pair<grpc::string, grpc::string> > metadata_;
friend class ::grpc::Server;
ServerContext(gpr_timespec deadline, grpc_metadata *metadata, size_t metadata_count);
const std::chrono::system_clock::time_point deadline_;
std::multimap<grpc::string, grpc::string> metadata_;
};
} // namespace grpc

@ -43,6 +43,8 @@ namespace grpc {
CompletionQueue::CompletionQueue() { cq_ = grpc_completion_queue_create(); }
CompletionQueue::CompletionQueue(grpc_completion_queue *take) : cq_(take) {}
CompletionQueue::~CompletionQueue() { grpc_completion_queue_destroy(cq_); }
void CompletionQueue::Shutdown() { grpc_completion_queue_shutdown(cq_); }

@ -32,5 +32,17 @@
*/
#include <grpc++/server_context.h>
#include <grpc/grpc.h>
#include "src/cpp/util/time.h"
namespace grpc {} // namespace grpc
namespace grpc {
ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata *metadata, size_t metadata_count)
: deadline_(Timespec2Timepoint(deadline)) {
for (size_t i = 0; i < metadata_count; i++) {
metadata_.insert(std::make_pair(grpc::string(metadata[i].key),
grpc::string(metadata[i].value, metadata[i].value + metadata[i].value_length)));
}
}
} // namespace grpc

Loading…
Cancel
Save