Skip to content

Commit

Permalink
After GrpcLibrary refactoring. Compiles and passes. WIP still
Browse files Browse the repository at this point in the history
  • Loading branch information
dgquintas committed Jan 28, 2016
1 parent 6a48405 commit e1300de
Show file tree
Hide file tree
Showing 31 changed files with 544 additions and 248 deletions.
11 changes: 11 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ cc_library(
"src/cpp/common/call.cc",
"src/cpp/common/channel_arguments.cc",
"src/cpp/common/completion_queue.cc",
"src/cpp/common/grpc_library_initializer.cc",
"src/cpp/common/rpc_method.cc",
"src/cpp/proto/proto_utils.cc",
"src/cpp/server/async_generic_service.cc",
Expand All @@ -801,6 +802,7 @@ cc_library(
"src/cpp/util/status.cc",
"src/cpp/util/string_ref.cc",
"src/cpp/util/time.cc",
"src/cpp/codegen/grpc_library.cc",
],
hdrs = [
"include/grpc++/channel.h",
Expand Down Expand Up @@ -854,6 +856,7 @@ cc_library(
"include/grpc++/impl/codegen/completion_queue_tag.h",
"include/grpc++/impl/codegen/config.h",
"include/grpc++/impl/codegen/config_protobuf.h",
"include/grpc++/impl/codegen/grpc_library.h",
"include/grpc++/impl/codegen/proto_utils.h",
"include/grpc++/impl/codegen/security/auth_context.h",
"include/grpc++/impl/codegen/serialization_traits.h",
Expand All @@ -863,6 +866,7 @@ cc_library(
"include/grpc++/impl/codegen/status.h",
"include/grpc++/impl/codegen/status_code_enum.h",
"include/grpc++/impl/codegen/string_ref.h",
"include/grpc++/impl/codegen/stub_options.h",
"include/grpc++/impl/codegen/sync.h",
"include/grpc++/impl/codegen/sync_cxx11.h",
"include/grpc++/impl/codegen/sync_no_cxx11.h",
Expand Down Expand Up @@ -900,6 +904,7 @@ cc_library(
"src/cpp/common/call.cc",
"src/cpp/common/channel_arguments.cc",
"src/cpp/common/completion_queue.cc",
"src/cpp/common/grpc_library_initializer.cc",
"src/cpp/common/rpc_method.cc",
"src/cpp/proto/proto_utils.cc",
"src/cpp/server/async_generic_service.cc",
Expand All @@ -916,6 +921,7 @@ cc_library(
"src/cpp/util/status.cc",
"src/cpp/util/string_ref.cc",
"src/cpp/util/time.cc",
"src/cpp/codegen/grpc_library.cc",
],
hdrs = [
"include/grpc++/channel.h",
Expand Down Expand Up @@ -969,6 +975,7 @@ cc_library(
"include/grpc++/impl/codegen/completion_queue_tag.h",
"include/grpc++/impl/codegen/config.h",
"include/grpc++/impl/codegen/config_protobuf.h",
"include/grpc++/impl/codegen/grpc_library.h",
"include/grpc++/impl/codegen/proto_utils.h",
"include/grpc++/impl/codegen/security/auth_context.h",
"include/grpc++/impl/codegen/serialization_traits.h",
Expand All @@ -978,6 +985,7 @@ cc_library(
"include/grpc++/impl/codegen/status.h",
"include/grpc++/impl/codegen/status_code_enum.h",
"include/grpc++/impl/codegen/string_ref.h",
"include/grpc++/impl/codegen/stub_options.h",
"include/grpc++/impl/codegen/sync.h",
"include/grpc++/impl/codegen/sync_cxx11.h",
"include/grpc++/impl/codegen/sync_no_cxx11.h",
Expand Down Expand Up @@ -1018,6 +1026,7 @@ cc_library(
"src/compiler/objective_c_generator.cc",
"src/compiler/python_generator.cc",
"src/compiler/ruby_generator.cc",
"src/cpp/codegen/grpc_library.cc",
],
hdrs = [
"include/grpc++/impl/codegen/async_stream.h",
Expand All @@ -1028,6 +1037,7 @@ cc_library(
"include/grpc++/impl/codegen/completion_queue_tag.h",
"include/grpc++/impl/codegen/config.h",
"include/grpc++/impl/codegen/config_protobuf.h",
"include/grpc++/impl/codegen/grpc_library.h",
"include/grpc++/impl/codegen/proto_utils.h",
"include/grpc++/impl/codegen/security/auth_context.h",
"include/grpc++/impl/codegen/serialization_traits.h",
Expand All @@ -1037,6 +1047,7 @@ cc_library(
"include/grpc++/impl/codegen/status.h",
"include/grpc++/impl/codegen/status_code_enum.h",
"include/grpc++/impl/codegen/string_ref.h",
"include/grpc++/impl/codegen/stub_options.h",
"include/grpc++/impl/codegen/sync.h",
"include/grpc++/impl/codegen/sync_cxx11.h",
"include/grpc++/impl/codegen/sync_no_cxx11.h",
Expand Down
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3010,6 +3010,7 @@ LIBGRPC++_SRC = \
src/cpp/common/call.cc \
src/cpp/common/channel_arguments.cc \
src/cpp/common/completion_queue.cc \
src/cpp/common/grpc_library_initializer.cc \
src/cpp/common/rpc_method.cc \
src/cpp/proto/proto_utils.cc \
src/cpp/server/async_generic_service.cc \
Expand All @@ -3026,6 +3027,7 @@ LIBGRPC++_SRC = \
src/cpp/util/status.cc \
src/cpp/util/string_ref.cc \
src/cpp/util/time.cc \
src/cpp/codegen/grpc_library.cc \

PUBLIC_HEADERS_CXX += \
include/grpc++/channel.h \
Expand Down Expand Up @@ -3079,6 +3081,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/completion_queue_tag.h \
include/grpc++/impl/codegen/config.h \
include/grpc++/impl/codegen/config_protobuf.h \
include/grpc++/impl/codegen/grpc_library.h \
include/grpc++/impl/codegen/proto_utils.h \
include/grpc++/impl/codegen/security/auth_context.h \
include/grpc++/impl/codegen/serialization_traits.h \
Expand All @@ -3088,6 +3091,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/status.h \
include/grpc++/impl/codegen/status_code_enum.h \
include/grpc++/impl/codegen/string_ref.h \
include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync.h \
include/grpc++/impl/codegen/sync_cxx11.h \
include/grpc++/impl/codegen/sync_no_cxx11.h \
Expand Down Expand Up @@ -3301,6 +3305,7 @@ LIBGRPC++_UNSECURE_SRC = \
src/cpp/common/call.cc \
src/cpp/common/channel_arguments.cc \
src/cpp/common/completion_queue.cc \
src/cpp/common/grpc_library_initializer.cc \
src/cpp/common/rpc_method.cc \
src/cpp/proto/proto_utils.cc \
src/cpp/server/async_generic_service.cc \
Expand All @@ -3317,6 +3322,7 @@ LIBGRPC++_UNSECURE_SRC = \
src/cpp/util/status.cc \
src/cpp/util/string_ref.cc \
src/cpp/util/time.cc \
src/cpp/codegen/grpc_library.cc \

PUBLIC_HEADERS_CXX += \
include/grpc++/channel.h \
Expand Down Expand Up @@ -3370,6 +3376,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/completion_queue_tag.h \
include/grpc++/impl/codegen/config.h \
include/grpc++/impl/codegen/config_protobuf.h \
include/grpc++/impl/codegen/grpc_library.h \
include/grpc++/impl/codegen/proto_utils.h \
include/grpc++/impl/codegen/security/auth_context.h \
include/grpc++/impl/codegen/serialization_traits.h \
Expand All @@ -3379,6 +3386,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/status.h \
include/grpc++/impl/codegen/status_code_enum.h \
include/grpc++/impl/codegen/string_ref.h \
include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync.h \
include/grpc++/impl/codegen/sync_cxx11.h \
include/grpc++/impl/codegen/sync_no_cxx11.h \
Expand Down Expand Up @@ -3458,6 +3466,7 @@ LIBGRPC_PLUGIN_SUPPORT_SRC = \
src/compiler/objective_c_generator.cc \
src/compiler/python_generator.cc \
src/compiler/ruby_generator.cc \
src/cpp/codegen/grpc_library.cc \

PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/async_stream.h \
Expand All @@ -3468,6 +3477,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/completion_queue_tag.h \
include/grpc++/impl/codegen/config.h \
include/grpc++/impl/codegen/config_protobuf.h \
include/grpc++/impl/codegen/grpc_library.h \
include/grpc++/impl/codegen/proto_utils.h \
include/grpc++/impl/codegen/security/auth_context.h \
include/grpc++/impl/codegen/serialization_traits.h \
Expand All @@ -3477,6 +3487,7 @@ PUBLIC_HEADERS_CXX += \
include/grpc++/impl/codegen/status.h \
include/grpc++/impl/codegen/status_code_enum.h \
include/grpc++/impl/codegen/string_ref.h \
include/grpc++/impl/codegen/stub_options.h \
include/grpc++/impl/codegen/sync.h \
include/grpc++/impl/codegen/sync_cxx11.h \
include/grpc++/impl/codegen/sync_no_cxx11.h \
Expand Down
6 changes: 5 additions & 1 deletion build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ filegroups:
- src/cpp/common/call.cc
- src/cpp/common/channel_arguments.cc
- src/cpp/common/completion_queue.cc
- src/cpp/common/grpc_library_initializer.cc
- src/cpp/common/rpc_method.cc
- src/cpp/proto/proto_utils.cc
- src/cpp/server/async_generic_service.cc
Expand All @@ -107,10 +108,10 @@ filegroups:
- include/grpc++/impl/codegen/call_hook.h
- include/grpc++/impl/codegen/channel_interface.h
- include/grpc++/impl/codegen/client_context.h
- include/grpc++/impl/codegen/stub_options.h
- include/grpc++/impl/codegen/completion_queue_tag.h
- include/grpc++/impl/codegen/config.h
- include/grpc++/impl/codegen/config_protobuf.h
- include/grpc++/impl/codegen/grpc_library.h
- include/grpc++/impl/codegen/proto_utils.h
- include/grpc++/impl/codegen/security/auth_context.h
- include/grpc++/impl/codegen/serialization_traits.h
Expand All @@ -120,10 +121,13 @@ filegroups:
- include/grpc++/impl/codegen/status.h
- include/grpc++/impl/codegen/status_code_enum.h
- include/grpc++/impl/codegen/string_ref.h
- include/grpc++/impl/codegen/stub_options.h
- include/grpc++/impl/codegen/sync.h
- include/grpc++/impl/codegen/sync_cxx11.h
- include/grpc++/impl/codegen/sync_no_cxx11.h
- include/grpc++/impl/codegen/time.h
src:
- src/cpp/codegen/grpc_library.cc
- name: grpc_base
public_headers:
- include/grpc/byte_buffer.h
Expand Down
9 changes: 5 additions & 4 deletions include/grpc++/alarm.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@
#ifndef GRPCXX_ALARM_H
#define GRPCXX_ALARM_H

#include <grpc++/completion_queue.h>
#include <grpc++/impl/grpc_library.h>
#include <grpc++/support/time.h>
#include <grpc++/impl/codegen/grpc_library.h>
#include <grpc++/impl/codegen/time.h>

namespace grpc {

class CompletionQueue;

/// A thin wrapper around \a grpc_alarm (see / \a / src/core/surface/alarm.h).
class Alarm : public GrpcLibrary {
class Alarm : private GrpcLibrary {
public:
/// Create a completion queue alarm instance associated to \a cq.
///
Expand Down
10 changes: 5 additions & 5 deletions include/grpc++/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,20 @@

#include <memory>

#include <grpc/grpc.h>
#include <grpc++/impl/call.h>
#include <grpc++/impl/codegen/channel_interface.h>
#include <grpc++/impl/grpc_library.h>
#include <grpc++/support/config.h>
#include <grpc++/impl/codegen/config.h>
#include <grpc++/impl/codegen/grpc_library.h>
#include <grpc/grpc.h>

struct grpc_channel;

namespace grpc {
/// Channels represent a connection to an endpoint. Created by \a CreateChannel.
class Channel GRPC_FINAL : public ChannelInterface,
public GrpcLibrary,
public CallHook,
public std::enable_shared_from_this<Channel> {
public std::enable_shared_from_this<Channel>,
private GrpcLibrary {
public:
~Channel();

Expand Down
10 changes: 5 additions & 5 deletions include/grpc++/completion_queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
#ifndef GRPCXX_COMPLETION_QUEUE_H
#define GRPCXX_COMPLETION_QUEUE_H

#include <grpc++/impl/grpc_library.h>
#include <grpc++/support/status.h>
#include <grpc++/support/time.h>
#include <grpc++/impl/codegen/grpc_library.h>
#include <grpc++/impl/codegen/status.h>
#include <grpc++/impl/codegen/time.h>

struct grpc_completion_queue;

Expand Down Expand Up @@ -78,7 +78,7 @@ class ServerContext;

/// A thin wrapper around \a grpc_completion_queue (see / \a
/// src/core/surface/completion_queue.h).
class CompletionQueue : public GrpcLibrary {
class CompletionQueue : private GrpcLibrary {
public:
/// Default constructor. Implicitly creates a \a grpc_completion_queue
/// instance.
Expand All @@ -90,7 +90,7 @@ class CompletionQueue : public GrpcLibrary {
explicit CompletionQueue(grpc_completion_queue* take);

/// Destructor. Destroys the owned wrapped completion queue / instance.
~CompletionQueue() GRPC_OVERRIDE;
~CompletionQueue();

/// Tri-state return for AsyncNext: SHUTDOWN, GOT_EVENT, TIMEOUT.
enum NextStatus {
Expand Down
6 changes: 3 additions & 3 deletions include/grpc++/impl/client_unary_call.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
#ifndef GRPCXX_IMPL_CLIENT_UNARY_CALL_H
#define GRPCXX_IMPL_CLIENT_UNARY_CALL_H

#include <grpc++/impl/call.h>
#include <grpc++/impl/codegen/call.h>
#include <grpc++/impl/codegen/channel_interface.h>
#include <grpc++/support/config.h>
#include <grpc++/support/status.h>
#include <grpc++/impl/codegen/config.h>
#include <grpc++/impl/codegen/status.h>

namespace grpc {

Expand Down
67 changes: 67 additions & 0 deletions include/grpc++/impl/codegen/grpc_library.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
*
* Copyright 2016, 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 GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H
#define GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H

#include <grpc/impl/codegen/log.h>

namespace grpc {

class GrpcLibraryInterface {
public:
virtual void init() = 0;
virtual void shutdown() = 0;
};

extern GrpcLibraryInterface* g_glip;

class GrpcLibrary {
public:
GrpcLibrary() {
GPR_ASSERT(g_glip &&
"gRPC library not initialized. See "
"grpc::internal::GrpcLibraryInitializer.");
g_glip->init();
}
virtual ~GrpcLibrary() {
GPR_ASSERT(g_glip &&
"gRPC library not initialized. See "
"grpc::internal::GrpcLibraryInitializer.");
g_glip->shutdown();
}
};

} // namespace grpc

#endif // GRPCXX_IMPL_GRPC_LIBRARY_H
Loading

0 comments on commit e1300de

Please sign in to comment.