aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/grpc++/completion_queue.h7
-rw-r--r--src/cpp/common/completion_queue.cc17
2 files changed, 14 insertions, 10 deletions
diff --git a/include/grpc++/completion_queue.h b/include/grpc++/completion_queue.h
index f4619a1060..e6a8c6fe55 100644
--- a/include/grpc++/completion_queue.h
+++ b/include/grpc++/completion_queue.h
@@ -36,6 +36,7 @@
#include <chrono>
#include <grpc++/impl/client_unary_call.h>
+#include <grpc/support/time.h>
struct grpc_completion_queue;
@@ -88,9 +89,7 @@ class CompletionQueue {
// Returns false if the queue is ready for destruction, true if event
bool Next(void** tag, bool* ok) {
- return (
- AsyncNext(tag, ok, (std::chrono::system_clock::time_point::max)()) !=
- SHUTDOWN);
+ return (AsyncNextInternal(tag, ok, gpr_inf_future) != SHUTDOWN);
}
// Shutdown has to be called, and the CompletionQueue can only be
@@ -122,6 +121,8 @@ class CompletionQueue {
const grpc::protobuf::Message& request,
grpc::protobuf::Message* result);
+ NextStatus AsyncNextInternal(void** tag, bool* ok, gpr_timespec deadline);
+
// Wraps grpc_completion_queue_pluck.
// Cannot be mixed with calls to Next().
bool Pluck(CompletionQueueTag* tag);
diff --git a/src/cpp/common/completion_queue.cc b/src/cpp/common/completion_queue.cc
index fede2da016..cea2d24831 100644
--- a/src/cpp/common/completion_queue.cc
+++ b/src/cpp/common/completion_queue.cc
@@ -36,7 +36,6 @@
#include <grpc/grpc.h>
#include <grpc/support/log.h>
-#include <grpc/support/time.h>
#include "src/cpp/util/time.h"
namespace grpc {
@@ -57,15 +56,12 @@ class EventDeleter {
}
};
-CompletionQueue::NextStatus
-CompletionQueue::AsyncNext(void** tag, bool* ok,
- std::chrono::system_clock::time_point deadline) {
+CompletionQueue::NextStatus CompletionQueue::AsyncNextInternal(
+ void** tag, bool* ok, gpr_timespec deadline) {
std::unique_ptr<grpc_event, EventDeleter> ev;
- gpr_timespec gpr_deadline;
- Timepoint2Timespec(deadline, &gpr_deadline);
for (;;) {
- ev.reset(grpc_completion_queue_next(cq_, gpr_deadline));
+ ev.reset(grpc_completion_queue_next(cq_, deadline));
if (!ev) { /* got a NULL back because deadline passed */
return TIMEOUT;
}
@@ -81,6 +77,13 @@ CompletionQueue::AsyncNext(void** tag, bool* ok,
}
}
+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;