aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpp')
-rw-r--r--src/cpp/client/channel.cc3
-rw-r--r--src/cpp/client/client_context.cc15
-rw-r--r--src/cpp/client/secure_credentials.cc12
-rw-r--r--src/cpp/common/completion_queue.cc9
-rw-r--r--src/cpp/server/server.cc4
-rw-r--r--src/cpp/server/server_context.cc8
-rw-r--r--src/cpp/util/time.cc7
-rw-r--r--src/cpp/util/time.h51
8 files changed, 22 insertions, 87 deletions
diff --git a/src/cpp/client/channel.cc b/src/cpp/client/channel.cc
index 5380d3a232..aaad042026 100644
--- a/src/cpp/client/channel.cc
+++ b/src/cpp/client/channel.cc
@@ -33,7 +33,6 @@
#include "src/cpp/client/channel.h"
-#include <chrono>
#include <memory>
#include <grpc/grpc.h>
@@ -64,7 +63,7 @@ Call Channel::CreateCall(const RpcMethod& method, ClientContext* context,
context->authority().empty()
? target_.c_str()
: context->authority().c_str(),
- context->RawDeadline());
+ context->raw_deadline());
context->set_call(c_call);
return Call(c_call, this, cq);
}
diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc
index de9f8c7201..70c9cb4c3b 100644
--- a/src/cpp/client/client_context.cc
+++ b/src/cpp/client/client_context.cc
@@ -34,9 +34,7 @@
#include <grpc++/client_context.h>
#include <grpc/grpc.h>
-#include "src/cpp/util/time.h"
-
-using std::chrono::system_clock;
+#include <grpc++/time.h>
namespace grpc {
@@ -44,7 +42,7 @@ ClientContext::ClientContext()
: initial_metadata_received_(false),
call_(nullptr),
cq_(nullptr),
- absolute_deadline_(gpr_inf_future) {}
+ deadline_(gpr_inf_future) {}
ClientContext::~ClientContext() {
if (call_) {
@@ -64,15 +62,6 @@ ClientContext::~ClientContext() {
}
}
-void ClientContext::set_absolute_deadline(
- const system_clock::time_point& deadline) {
- Timepoint2Timespec(deadline, &absolute_deadline_);
-}
-
-system_clock::time_point ClientContext::absolute_deadline() {
- return Timespec2Timepoint(absolute_deadline_);
-}
-
void ClientContext::AddMetadata(const grpc::string& meta_key,
const grpc::string& meta_value) {
send_initial_metadata_.insert(std::make_pair(meta_key, meta_value));
diff --git a/src/cpp/client/secure_credentials.cc b/src/cpp/client/secure_credentials.cc
index d6f9acc675..85785ed275 100644
--- a/src/cpp/client/secure_credentials.cc
+++ b/src/cpp/client/secure_credentials.cc
@@ -96,27 +96,27 @@ std::unique_ptr<Credentials> ComputeEngineCredentials() {
// Builds service account credentials.
std::unique_ptr<Credentials> ServiceAccountCredentials(
const grpc::string& json_key, const grpc::string& scope,
- std::chrono::seconds token_lifetime) {
- if (token_lifetime.count() <= 0) {
+ long token_lifetime) {
+ if (token_lifetime <= 0) {
gpr_log(GPR_ERROR,
"Trying to create ServiceAccountCredentials "
"with non-positive lifetime");
return WrapCredentials(nullptr);
}
- gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime.count());
+ gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime);
return WrapCredentials(grpc_service_account_credentials_create(
json_key.c_str(), scope.c_str(), lifetime));
}
// Builds JWT credentials.
std::unique_ptr<Credentials> JWTCredentials(
- const grpc::string& json_key, std::chrono::seconds token_lifetime) {
- if (token_lifetime.count() <= 0) {
+ const grpc::string& json_key, long token_lifetime) {
+ if (token_lifetime <= 0) {
gpr_log(GPR_ERROR,
"Trying to create JWTCredentials with non-positive lifetime");
return WrapCredentials(nullptr);
}
- gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime.count());
+ gpr_timespec lifetime = gpr_time_from_seconds(token_lifetime);
return WrapCredentials(
grpc_jwt_credentials_create(json_key.c_str(), lifetime));
}
diff --git a/src/cpp/common/completion_queue.cc b/src/cpp/common/completion_queue.cc
index cea2d24831..3c37e91e1f 100644
--- a/src/cpp/common/completion_queue.cc
+++ b/src/cpp/common/completion_queue.cc
@@ -36,7 +36,7 @@
#include <grpc/grpc.h>
#include <grpc/support/log.h>
-#include "src/cpp/util/time.h"
+#include <grpc++/time.h>
namespace grpc {
@@ -77,13 +77,6 @@ CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal(
}
}
-CompletionQueue::NextStatus CompletionQueue::AsyncNext(
- void** tag, bool* ok, std::chrono::system_clock::time_point deadline) {
- gpr_timespec gpr_deadline;
- Timepoint2Timespec(deadline, &gpr_deadline);
- return AsyncNextInternal(tag, ok, gpr_deadline);
-}
-
bool CompletionQueue::Pluck(CompletionQueueTag* tag) {
std::unique_ptr<grpc_event, EventDeleter> ev;
diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc
index 046133c5eb..2833f78a75 100644
--- a/src/cpp/server/server.cc
+++ b/src/cpp/server/server.cc
@@ -45,9 +45,9 @@
#include <grpc++/server_context.h>
#include <grpc++/server_credentials.h>
#include <grpc++/thread_pool_interface.h>
+#include <grpc++/time.h>
#include "src/cpp/proto/proto_utils.h"
-#include "src/cpp/util/time.h"
namespace grpc {
@@ -348,7 +348,7 @@ class Server::AsyncRequest GRPC_FINAL : public CompletionQueueTag {
ServerContext* ctx = ctx_ ? ctx_ : generic_ctx_;
GPR_ASSERT(ctx);
if (*status) {
- ctx->deadline_ = Timespec2Timepoint(call_details_.deadline);
+ ctx->deadline_ = call_details_.deadline;
for (size_t i = 0; i < array_.count; i++) {
ctx->client_metadata_.insert(std::make_pair(
grpc::string(array_.metadata[i].key),
diff --git a/src/cpp/server/server_context.cc b/src/cpp/server/server_context.cc
index ffd6d30d5d..6b5e41d0a8 100644
--- a/src/cpp/server/server_context.cc
+++ b/src/cpp/server/server_context.cc
@@ -33,11 +33,11 @@
#include <grpc++/server_context.h>
-#include <grpc++/impl/call.h>
-#include <grpc++/impl/sync.h>
#include <grpc/grpc.h>
#include <grpc/support/log.h>
-#include "src/cpp/util/time.h"
+#include <grpc++/impl/call.h>
+#include <grpc++/impl/sync.h>
+#include <grpc++/time.h>
namespace grpc {
@@ -99,7 +99,7 @@ ServerContext::ServerContext()
ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata* metadata,
size_t metadata_count)
: completion_op_(nullptr),
- deadline_(Timespec2Timepoint(deadline)),
+ deadline_(deadline),
call_(nullptr),
cq_(nullptr),
sent_initial_metadata_(false) {
diff --git a/src/cpp/util/time.cc b/src/cpp/util/time.cc
index 059ea72abf..1fef2a56de 100644
--- a/src/cpp/util/time.cc
+++ b/src/cpp/util/time.cc
@@ -31,9 +31,12 @@
*
*/
-#include "src/cpp/util/time.h"
+#include <grpc++/config.h>
+
+#ifndef GRPC_CXX0X_NO_CHRONO
#include <grpc/support/time.h>
+#include <grpc++/time.h>
using std::chrono::duration_cast;
using std::chrono::nanoseconds;
@@ -68,3 +71,5 @@ system_clock::time_point Timespec2Timepoint(gpr_timespec t) {
}
} // namespace grpc
+
+#endif // !GRPC_CXX0X_NO_CHRONO
diff --git a/src/cpp/util/time.h b/src/cpp/util/time.h
deleted file mode 100644
index 8b7fcf55f7..0000000000
--- a/src/cpp/util/time.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- *
- * Copyright 2015, Google Inc.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- * * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-#ifndef GRPC_INTERNAL_CPP_UTIL_TIME_H
-#define GRPC_INTERNAL_CPP_UTIL_TIME_H
-
-#include <chrono>
-
-#include <grpc/support/time.h>
-
-namespace grpc {
-
-// from and to should be absolute time.
-void Timepoint2Timespec(const std::chrono::system_clock::time_point& from,
- gpr_timespec* to);
-
-std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t);
-
-} // namespace grpc
-
-#endif // GRPC_INTERNAL_CPP_UTIL_TIME_H