aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Nicolas Noble <nicolasnoble@users.noreply.github.com>2018-12-13 15:22:05 -0800
committerGravatar GitHub <noreply@github.com>2018-12-13 15:22:05 -0800
commit5748af6e1876ab9beda827266b2045c89398b7ef (patch)
tree9b7adf99c52b371bf018ddb4a5b7aa8c38bb72d7
parentc262d4c576b5e83f00ddff82f24b0b0b29a06649 (diff)
parentd550af373cc993ee80e9e350d60f4ca662b1ec28 (diff)
Merge pull request #17468 from nicolasnoble/grpc_namespace
Moving ::grpc::Alarm to ::grpc_impl::Alarm.
-rw-r--r--BUILD1
-rw-r--r--CMakeLists.txt3
-rw-r--r--Makefile3
-rw-r--r--build.yaml1
-rw-r--r--gRPC-C++.podspec1
-rw-r--r--include/grpcpp/alarm.h93
-rw-r--r--include/grpcpp/alarm_impl.h116
-rw-r--r--src/cpp/common/alarm.cc13
-rw-r--r--tools/doxygen/Doxyfile.c++1
-rw-r--r--tools/doxygen/Doxyfile.c++.internal1
-rw-r--r--tools/run_tests/generated/sources_and_headers.json2
11 files changed, 140 insertions, 95 deletions
diff --git a/BUILD b/BUILD
index 5550e583a8..fe93f1281e 100644
--- a/BUILD
+++ b/BUILD
@@ -204,6 +204,7 @@ GRPCXX_PUBLIC_HDRS = [
"include/grpc++/support/sync_stream.h",
"include/grpc++/support/time.h",
"include/grpcpp/alarm.h",
+ "include/grpcpp/alarm_impl.h",
"include/grpcpp/channel.h",
"include/grpcpp/client_context.h",
"include/grpcpp/completion_queue.h",
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9c660c7701..fb233cc360 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2985,6 +2985,7 @@ foreach(_hdr
include/grpc++/support/sync_stream.h
include/grpc++/support/time.h
include/grpcpp/alarm.h
+ include/grpcpp/alarm_impl.h
include/grpcpp/channel.h
include/grpcpp/client_context.h
include/grpcpp/completion_queue.h
@@ -3569,6 +3570,7 @@ foreach(_hdr
include/grpc++/support/sync_stream.h
include/grpc++/support/time.h
include/grpcpp/alarm.h
+ include/grpcpp/alarm_impl.h
include/grpcpp/channel.h
include/grpcpp/client_context.h
include/grpcpp/completion_queue.h
@@ -4520,6 +4522,7 @@ foreach(_hdr
include/grpc++/support/sync_stream.h
include/grpc++/support/time.h
include/grpcpp/alarm.h
+ include/grpcpp/alarm_impl.h
include/grpcpp/channel.h
include/grpcpp/client_context.h
include/grpcpp/completion_queue.h
diff --git a/Makefile b/Makefile
index 0163dc414a..c4d8a0b95c 100644
--- a/Makefile
+++ b/Makefile
@@ -5356,6 +5356,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/support/sync_stream.h \
include/grpc++/support/time.h \
include/grpcpp/alarm.h \
+ include/grpcpp/alarm_impl.h \
include/grpcpp/channel.h \
include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \
@@ -5949,6 +5950,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/support/sync_stream.h \
include/grpc++/support/time.h \
include/grpcpp/alarm.h \
+ include/grpcpp/alarm_impl.h \
include/grpcpp/channel.h \
include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \
@@ -6857,6 +6859,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/support/sync_stream.h \
include/grpc++/support/time.h \
include/grpcpp/alarm.h \
+ include/grpcpp/alarm_impl.h \
include/grpcpp/channel.h \
include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \
diff --git a/build.yaml b/build.yaml
index 4521169e6c..6e2ed16398 100644
--- a/build.yaml
+++ b/build.yaml
@@ -1325,6 +1325,7 @@ filegroups:
- include/grpc++/support/sync_stream.h
- include/grpc++/support/time.h
- include/grpcpp/alarm.h
+ - include/grpcpp/alarm_impl.h
- include/grpcpp/channel.h
- include/grpcpp/client_context.h
- include/grpcpp/completion_queue.h
diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec
index 30fcb51ee1..414e788a96 100644
--- a/gRPC-C++.podspec
+++ b/gRPC-C++.podspec
@@ -78,6 +78,7 @@ Pod::Spec.new do |s|
ss.header_mappings_dir = 'include/grpcpp'
ss.source_files = 'include/grpcpp/alarm.h',
+ 'include/grpcpp/alarm_impl.h',
'include/grpcpp/channel.h',
'include/grpcpp/client_context.h',
'include/grpcpp/completion_queue.h',
diff --git a/include/grpcpp/alarm.h b/include/grpcpp/alarm.h
index 365feb4eb9..2343c1149c 100644
--- a/include/grpcpp/alarm.h
+++ b/include/grpcpp/alarm.h
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015 gRPC authors.
+ * Copyright 2018 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,99 +16,14 @@
*
*/
-/// An Alarm posts the user provided tag to its associated completion queue upon
-/// expiry or cancellation.
#ifndef GRPCPP_ALARM_H
#define GRPCPP_ALARM_H
-#include <functional>
-
-#include <grpc/grpc.h>
-#include <grpcpp/impl/codegen/completion_queue.h>
-#include <grpcpp/impl/codegen/completion_queue_tag.h>
-#include <grpcpp/impl/codegen/grpc_library.h>
-#include <grpcpp/impl/codegen/time.h>
-#include <grpcpp/impl/grpc_library.h>
+#include <grpcpp/alarm_impl.h>
namespace grpc {
-/// 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();
-
- /// 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.
- /// This form is deprecated because it is inherently racy.
- /// \internal We rely on the presence of \a cq for grpc initialization. If \a
- /// cq were ever to be removed, a reference to a static
- /// internal::GrpcLibraryInitializer instance would need to be introduced
- /// here. \endinternal.
- template <typename T>
- 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.
- /// Once the alarm expires (at \a deadline) or it's cancelled (see \a 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).
- template <typename T>
- void Set(CompletionQueue* cq, const T& deadline, void* tag) {
- SetInternal(cq, TimePoint<T>(deadline).raw_time(), tag);
- }
-
- /// Alarms aren't copyable.
- Alarm(const Alarm&) = delete;
- Alarm& operator=(const Alarm&) = delete;
-
- /// Alarms are movable.
- Alarm(Alarm&& rhs) : alarm_(rhs.alarm_) { rhs.alarm_ = nullptr; }
- Alarm& operator=(Alarm&& rhs) {
- alarm_ = rhs.alarm_;
- rhs.alarm_ = nullptr;
- return *this;
- }
-
- /// Cancel a completion queue alarm. Calling this function over an alarm that
- /// has already fired has no effect.
- void Cancel();
-
- /// NOTE: class experimental_type is not part of the public API of this class
- /// TODO(vjpai): Move these contents to the public API of Alarm when
- /// they are no longer experimental
- class experimental_type {
- public:
- explicit experimental_type(Alarm* alarm) : alarm_(alarm) {}
-
- /// Set an alarm to invoke callback \a f. The argument to the callback
- /// states whether the alarm expired at \a deadline (true) or was cancelled
- /// (false)
- template <typename T>
- void Set(const T& deadline, std::function<void(bool)> f) {
- alarm_->SetInternal(TimePoint<T>(deadline).raw_time(), std::move(f));
- }
-
- private:
- Alarm* alarm_;
- };
-
- /// NOTE: The function experimental() is not stable public API. It is a view
- /// to the experimental components of this class. It may be changed or removed
- /// at any time.
- experimental_type experimental() { return experimental_type(this); }
-
- private:
- void SetInternal(CompletionQueue* cq, gpr_timespec deadline, void* tag);
- void SetInternal(gpr_timespec deadline, std::function<void(bool)> f);
-
- internal::CompletionQueueTag* alarm_;
-};
-
-} // namespace grpc
+typedef ::grpc_impl::Alarm Alarm;
+}
#endif // GRPCPP_ALARM_H
diff --git a/include/grpcpp/alarm_impl.h b/include/grpcpp/alarm_impl.h
new file mode 100644
index 0000000000..7844e7c886
--- /dev/null
+++ b/include/grpcpp/alarm_impl.h
@@ -0,0 +1,116 @@
+/*
+ *
+ * Copyright 2015 gRPC authors.
+ *
+ * Licensed 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.
+ *
+ */
+
+/// An Alarm posts the user provided tag to its associated completion queue upon
+/// expiry or cancellation.
+#ifndef GRPCPP_ALARM_IMPL_H
+#define GRPCPP_ALARM_IMPL_H
+
+#include <functional>
+
+#include <grpc/grpc.h>
+#include <grpcpp/impl/codegen/completion_queue.h>
+#include <grpcpp/impl/codegen/completion_queue_tag.h>
+#include <grpcpp/impl/codegen/grpc_library.h>
+#include <grpcpp/impl/codegen/time.h>
+#include <grpcpp/impl/grpc_library.h>
+
+namespace grpc_impl {
+
+/// A thin wrapper around \a grpc_alarm (see / \a / src/core/surface/alarm.h).
+class Alarm : private ::grpc::GrpcLibraryCodegen {
+ public:
+ /// Create an unset completion queue alarm
+ 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.
+ /// This form is deprecated because it is inherently racy.
+ /// \internal We rely on the presence of \a cq for grpc initialization. If \a
+ /// cq were ever to be removed, a reference to a static
+ /// internal::GrpcLibraryInitializer instance would need to be introduced
+ /// here. \endinternal.
+ template <typename T>
+ Alarm(::grpc::CompletionQueue* cq, const T& deadline, void* tag) : Alarm() {
+ SetInternal(cq, ::grpc::TimePoint<T>(deadline).raw_time(), tag);
+ }
+
+ /// Trigger an alarm instance on completion queue \a cq at the specified time.
+ /// Once the alarm expires (at \a deadline) or it's cancelled (see \a 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).
+ template <typename T>
+ void Set(::grpc::CompletionQueue* cq, const T& deadline, void* tag) {
+ SetInternal(cq, ::grpc::TimePoint<T>(deadline).raw_time(), tag);
+ }
+
+ /// Alarms aren't copyable.
+ Alarm(const Alarm&) = delete;
+ Alarm& operator=(const Alarm&) = delete;
+
+ /// Alarms are movable.
+ Alarm(Alarm&& rhs) : alarm_(rhs.alarm_) { rhs.alarm_ = nullptr; }
+ Alarm& operator=(Alarm&& rhs) {
+ alarm_ = rhs.alarm_;
+ rhs.alarm_ = nullptr;
+ return *this;
+ }
+
+ /// Cancel a completion queue alarm. Calling this function over an alarm that
+ /// has already fired has no effect.
+ void Cancel();
+
+ /// NOTE: class experimental_type is not part of the public API of this class
+ /// TODO(vjpai): Move these contents to the public API of Alarm when
+ /// they are no longer experimental
+ class experimental_type {
+ public:
+ explicit experimental_type(Alarm* alarm) : alarm_(alarm) {}
+
+ /// Set an alarm to invoke callback \a f. The argument to the callback
+ /// states whether the alarm expired at \a deadline (true) or was cancelled
+ /// (false)
+ template <typename T>
+ void Set(const T& deadline, std::function<void(bool)> f) {
+ alarm_->SetInternal(::grpc::TimePoint<T>(deadline).raw_time(),
+ std::move(f));
+ }
+
+ private:
+ Alarm* alarm_;
+ };
+
+ /// NOTE: The function experimental() is not stable public API. It is a view
+ /// to the experimental components of this class. It may be changed or removed
+ /// at any time.
+ experimental_type experimental() { return experimental_type(this); }
+
+ private:
+ void SetInternal(::grpc::CompletionQueue* cq, gpr_timespec deadline,
+ void* tag);
+ void SetInternal(gpr_timespec deadline, std::function<void(bool)> f);
+
+ ::grpc::internal::CompletionQueueTag* alarm_;
+};
+
+} // namespace grpc_impl
+
+#endif // GRPCPP_ALARM_IMPL_H
diff --git a/src/cpp/common/alarm.cc b/src/cpp/common/alarm.cc
index 5819a4210b..148f0b9bc9 100644
--- a/src/cpp/common/alarm.cc
+++ b/src/cpp/common/alarm.cc
@@ -31,10 +31,10 @@
#include <grpc/support/log.h>
#include "src/core/lib/debug/trace.h"
-namespace grpc {
+namespace grpc_impl {
namespace internal {
-class AlarmImpl : public CompletionQueueTag {
+class AlarmImpl : public ::grpc::internal::CompletionQueueTag {
public:
AlarmImpl() : cq_(nullptr), tag_(nullptr) {
gpr_ref_init(&refs_, 1);
@@ -51,7 +51,7 @@ class AlarmImpl : public CompletionQueueTag {
Unref();
return true;
}
- void Set(CompletionQueue* cq, gpr_timespec deadline, void* tag) {
+ void Set(::grpc::CompletionQueue* cq, gpr_timespec deadline, void* tag) {
grpc_core::ExecCtx exec_ctx;
GRPC_CQ_INTERNAL_REF(cq->cq(), "alarm");
cq_ = cq->cq();
@@ -114,13 +114,14 @@ class AlarmImpl : public CompletionQueueTag {
};
} // namespace internal
-static internal::GrpcLibraryInitializer g_gli_initializer;
+static ::grpc::internal::GrpcLibraryInitializer g_gli_initializer;
Alarm::Alarm() : alarm_(new internal::AlarmImpl()) {
g_gli_initializer.summon();
}
-void Alarm::SetInternal(CompletionQueue* cq, gpr_timespec deadline, void* tag) {
+void Alarm::SetInternal(::grpc::CompletionQueue* cq, gpr_timespec deadline,
+ void* tag) {
// Note that we know that alarm_ is actually an internal::AlarmImpl
// but we declared it as the base pointer to avoid a forward declaration
// or exposing core data structures in the C++ public headers.
@@ -145,4 +146,4 @@ Alarm::~Alarm() {
}
void Alarm::Cancel() { static_cast<internal::AlarmImpl*>(alarm_)->Cancel(); }
-} // namespace grpc
+} // namespace grpc_impl
diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++
index 5c19711ee9..a5f817997d 100644
--- a/tools/doxygen/Doxyfile.c++
+++ b/tools/doxygen/Doxyfile.c++
@@ -925,6 +925,7 @@ include/grpc/support/thd_id.h \
include/grpc/support/time.h \
include/grpc/support/workaround_list.h \
include/grpcpp/alarm.h \
+include/grpcpp/alarm_impl.h \
include/grpcpp/channel.h \
include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \
diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal
index 0e65bf6daa..1535aa06d3 100644
--- a/tools/doxygen/Doxyfile.c++.internal
+++ b/tools/doxygen/Doxyfile.c++.internal
@@ -926,6 +926,7 @@ include/grpc/support/thd_id.h \
include/grpc/support/time.h \
include/grpc/support/workaround_list.h \
include/grpcpp/alarm.h \
+include/grpcpp/alarm_impl.h \
include/grpcpp/channel.h \
include/grpcpp/client_context.h \
include/grpcpp/completion_queue.h \
diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json
index 2451101f58..c87d7209e7 100644
--- a/tools/run_tests/generated/sources_and_headers.json
+++ b/tools/run_tests/generated/sources_and_headers.json
@@ -11447,6 +11447,7 @@
"include/grpc++/support/sync_stream.h",
"include/grpc++/support/time.h",
"include/grpcpp/alarm.h",
+ "include/grpcpp/alarm_impl.h",
"include/grpcpp/channel.h",
"include/grpcpp/client_context.h",
"include/grpcpp/completion_queue.h",
@@ -11552,6 +11553,7 @@
"include/grpc++/support/sync_stream.h",
"include/grpc++/support/time.h",
"include/grpcpp/alarm.h",
+ "include/grpcpp/alarm_impl.h",
"include/grpcpp/channel.h",
"include/grpcpp/client_context.h",
"include/grpcpp/completion_queue.h",