diff options
author | Vijay Pai <vpai@google.com> | 2018-02-02 11:21:07 -0800 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2018-02-02 11:21:07 -0800 |
commit | 1acfaca3e630fbb4c64de1eb7267f969730e49da (patch) | |
tree | 08619d38599aeb5dfdff0a7b341a07014f7ea4d1 /include | |
parent | 7ce8b94b691e08efc7206ac9365d71502872e154 (diff) | |
parent | c8e07c4964c98fb216dfcd562229ae515fc84a09 (diff) |
Merge branch 'master' into gpr_review_host_port
Diffstat (limited to 'include')
-rw-r--r-- | include/grpc++/alarm.h | 49 | ||||
-rw-r--r-- | include/grpc++/impl/codegen/call.h | 4 | ||||
-rw-r--r-- | include/grpc/grpc.h | 19 | ||||
-rw-r--r-- | include/grpc/impl/codegen/grpc_types.h | 3 |
4 files changed, 16 insertions, 59 deletions
diff --git a/include/grpc++/alarm.h b/include/grpc++/alarm.h index b43425e224..37d4189201 100644 --- a/include/grpc++/alarm.h +++ b/include/grpc++/alarm.h @@ -28,17 +28,16 @@ #include <grpc++/impl/grpc_library.h> #include <grpc/grpc.h> -struct grpc_alarm; - namespace grpc { -class CompletionQueue; - /// A thin wrapper around \a grpc_alarm (see / \a / src/core/surface/alarm.h). class Alarm : private GrpcLibraryCodegen { public: /// Create an unset completion queue alarm - Alarm() : tag_(nullptr), alarm_(grpc_alarm_create(nullptr)) {} + Alarm(); + + /// Destroy the given completion queue alarm, cancelling it in the process. + ~Alarm(); /// DEPRECATED: Create and set a completion queue alarm instance associated to /// \a cq. @@ -48,10 +47,8 @@ class Alarm : private GrpcLibraryCodegen { /// internal::GrpcLibraryInitializer instance would need to be introduced /// here. \endinternal. template <typename T> - Alarm(CompletionQueue* cq, const T& deadline, void* tag) - : tag_(tag), alarm_(grpc_alarm_create(nullptr)) { - grpc_alarm_set(alarm_, cq->cq(), TimePoint<T>(deadline).raw_time(), - static_cast<void*>(&tag_), nullptr); + Alarm(CompletionQueue* cq, const T& deadline, void* tag) : Alarm() { + SetInternal(cq, TimePoint<T>(deadline).raw_time(), tag); } /// Trigger an alarm instance on completion queue \a cq at the specified time. @@ -60,9 +57,7 @@ class Alarm : private GrpcLibraryCodegen { /// event's success bit will be true, false otherwise (ie, upon cancellation). template <typename T> void Set(CompletionQueue* cq, const T& deadline, void* tag) { - tag_.Set(tag); - grpc_alarm_set(alarm_, cq->cq(), TimePoint<T>(deadline).raw_time(), - static_cast<void*>(&tag_), nullptr); + SetInternal(cq, TimePoint<T>(deadline).raw_time(), tag); } /// Alarms aren't copyable. @@ -70,43 +65,21 @@ class Alarm : private GrpcLibraryCodegen { Alarm& operator=(const Alarm&) = delete; /// Alarms are movable. - Alarm(Alarm&& rhs) : tag_(rhs.tag_), alarm_(rhs.alarm_) { - rhs.alarm_ = nullptr; - } + Alarm(Alarm&& rhs) : alarm_(rhs.alarm_) { rhs.alarm_ = nullptr; } Alarm& operator=(Alarm&& rhs) { - tag_ = rhs.tag_; alarm_ = rhs.alarm_; rhs.alarm_ = nullptr; return *this; } - /// Destroy the given completion queue alarm, cancelling it in the process. - ~Alarm() { - if (alarm_ != nullptr) grpc_alarm_destroy(alarm_, nullptr); - } - /// Cancel a completion queue alarm. Calling this function over an alarm that /// has already fired has no effect. - void Cancel() { - if (alarm_ != nullptr) grpc_alarm_cancel(alarm_, nullptr); - } + void Cancel(); private: - class AlarmEntry : public internal::CompletionQueueTag { - public: - AlarmEntry(void* tag) : tag_(tag) {} - void Set(void* tag) { tag_ = tag; } - bool FinalizeResult(void** tag, bool* status) override { - *tag = tag_; - return true; - } - - private: - void* tag_; - }; + void SetInternal(CompletionQueue* cq, gpr_timespec deadline, void* tag); - AlarmEntry tag_; - grpc_alarm* alarm_; // owned + internal::CompletionQueueTag* alarm_; }; } // namespace grpc diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h index 2758e94c5e..c04526c59b 100644 --- a/include/grpc++/impl/codegen/call.h +++ b/include/grpc++/impl/codegen/call.h @@ -607,7 +607,7 @@ class CallOpSetInterface : public CompletionQueueTag { virtual void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) = 0; }; -/// Primary implementaiton of CallOpSetInterface. +/// Primary implementation of CallOpSetInterface. /// Since we cannot use variadic templates, we declare slots up to /// the maximum count of ops we'll need in a set. We leverage the /// empty base class optimization to slim this class (especially @@ -624,7 +624,7 @@ class CallOpSet : public CallOpSetInterface, public Op5, public Op6 { public: - CallOpSet() : return_tag_(this) {} + CallOpSet() : return_tag_(this), call_(nullptr) {} void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) override { this->Op1::AddOp(ops, nops); this->Op2::AddOp(ops, nops); diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index f083bc591e..47d749c728 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -160,25 +160,6 @@ GRPCAPI void grpc_completion_queue_thread_local_cache_init( GRPCAPI int grpc_completion_queue_thread_local_cache_flush( grpc_completion_queue* cq, void** tag, int* ok); -/** Create a completion queue alarm instance */ -GRPCAPI grpc_alarm* grpc_alarm_create(void* reserved); - -/** Set a completion queue alarm instance associated to \a cq. - * - * Once the alarm expires (at \a deadline) or it's cancelled (see \a - * grpc_alarm_cancel), an event with tag \a tag will be added to \a cq. If the - * alarm expired, the event's success bit will be true, false otherwise (ie, - * upon cancellation). */ -GRPCAPI void grpc_alarm_set(grpc_alarm* alarm, grpc_completion_queue* cq, - gpr_timespec deadline, void* tag, void* reserved); - -/** Cancel a completion queue alarm. Calling this function over an alarm that - * has already fired has no effect. */ -GRPCAPI void grpc_alarm_cancel(grpc_alarm* alarm, void* reserved); - -/** Destroy the given completion queue alarm, cancelling it in the process. */ -GRPCAPI void grpc_alarm_destroy(grpc_alarm* alarm, void* reserved); - /** Check the connectivity state of a channel. */ GRPCAPI grpc_connectivity_state grpc_channel_check_connectivity_state( grpc_channel* channel, int try_to_connect); diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index e5aa29b88a..d64b23f332 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -239,6 +239,9 @@ typedef struct { /** The time between the first and second connection attempts, in ms */ #define GRPC_ARG_INITIAL_RECONNECT_BACKOFF_MS \ "grpc.initial_reconnect_backoff_ms" +/** Minimum amount of time between DNS resolutions, in ms */ +#define GRPC_ARG_DNS_MIN_TIME_BETWEEN_RESOLUTIONS_MS \ + "grpc.dns_min_time_between_resolutions_ms" /** The timeout used on servers for finishing handshaking on an incoming connection. Defaults to 120 seconds. */ #define GRPC_ARG_SERVER_HANDSHAKE_TIMEOUT_MS "grpc.server_handshake_timeout_ms" |