GRPC C++  1.4.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
core_codegen_interface.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015, Google Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are
8  * met:
9  *
10  * * Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  * * Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following disclaimer
14  * in the documentation and/or other materials provided with the
15  * distribution.
16  * * Neither the name of Google Inc. nor the names of its
17  * contributors may be used to endorse or promote products derived from
18  * this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
33 
34 #ifndef GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H
35 #define GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H
36 
41 #include <grpc/impl/codegen/sync.h>
42 
43 extern "C" {
44 struct grpc_byte_buffer;
45 }
46 
47 namespace grpc {
48 
57  public:
59  virtual void assert_fail(const char* failed_assertion, const char* file,
60  int line) = 0;
61 
62  virtual const grpc_completion_queue_factory*
64  const grpc_completion_queue_attributes* attributes) = 0;
66  const grpc_completion_queue_factory* factory,
67  const grpc_completion_queue_attributes* attributes, void* reserved) = 0;
69  void* reserved) = 0;
71  void* reserved) = 0;
74  void* tag,
75  gpr_timespec deadline,
76  void* reserved) = 0;
77 
78  virtual void* gpr_malloc(size_t size) = 0;
79  virtual void gpr_free(void* p) = 0;
80 
81  virtual void gpr_mu_init(gpr_mu* mu) = 0;
82  virtual void gpr_mu_destroy(gpr_mu* mu) = 0;
83  virtual void gpr_mu_lock(gpr_mu* mu) = 0;
84  virtual void gpr_mu_unlock(gpr_mu* mu) = 0;
85  virtual void gpr_cv_init(gpr_cv* cv) = 0;
86  virtual void gpr_cv_destroy(gpr_cv* cv) = 0;
87  virtual int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu,
88  gpr_timespec abs_deadline) = 0;
89  virtual void gpr_cv_signal(gpr_cv* cv) = 0;
90  virtual void gpr_cv_broadcast(gpr_cv* cv) = 0;
91 
92  virtual void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) = 0;
93 
95  grpc_byte_buffer* buffer)
98  grpc_byte_buffer_reader* reader) = 0;
100  grpc_slice* slice) = 0;
101 
103  size_t nslices) = 0;
104  virtual grpc_slice grpc_slice_new_with_user_data(void* p, size_t len,
105  void (*destroy)(void*),
106  void* user_data) = 0;
107  virtual void grpc_call_ref(grpc_call* call) = 0;
108  virtual void grpc_call_unref(grpc_call* call) = 0;
109  virtual void* grpc_call_arena_alloc(grpc_call* call, size_t length) = 0;
110  virtual grpc_slice grpc_empty_slice() = 0;
111  virtual grpc_slice grpc_slice_malloc(size_t length) = 0;
112  virtual void grpc_slice_unref(grpc_slice slice) = 0;
113  virtual grpc_slice grpc_slice_ref(grpc_slice slice) = 0;
114  virtual grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) = 0;
115  virtual grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split) = 0;
116  virtual void grpc_slice_buffer_add(grpc_slice_buffer* sb,
117  grpc_slice slice) = 0;
118  virtual void grpc_slice_buffer_pop(grpc_slice_buffer* sb) = 0;
119  virtual grpc_slice grpc_slice_from_static_buffer(const void* buffer,
120  size_t length) = 0;
121  virtual grpc_slice grpc_slice_from_copied_buffer(const void* buffer,
122  size_t length) = 0;
123 
124  virtual void grpc_metadata_array_init(grpc_metadata_array* array) = 0;
125  virtual void grpc_metadata_array_destroy(grpc_metadata_array* array) = 0;
126 
127  virtual const Status& ok() = 0;
128  virtual const Status& cancelled() = 0;
129 
130  virtual gpr_timespec gpr_inf_future(gpr_clock_type type) = 0;
131  virtual gpr_timespec gpr_time_0(gpr_clock_type type) = 0;
132 };
133 
135 
137 #define GPR_CODEGEN_ASSERT(x) \
138  do { \
139  if (!(x)) { \
140  grpc::g_core_codegen_interface->assert_fail(#x, __FILE__, __LINE__); \
141  } \
142  } while (0)
143 
144 } // namespace grpc
145 
146 #endif // GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:86
virtual void grpc_slice_buffer_pop(grpc_slice_buffer *sb)=0
virtual const grpc_completion_queue_factory * grpc_completion_queue_factory_lookup(const grpc_completion_queue_attributes *attributes)=0
virtual void gpr_mu_unlock(gpr_mu *mu)=0
virtual grpc_slice grpc_slice_malloc(size_t length)=0
virtual void grpc_call_ref(grpc_call *call)=0
struct grpc_completion_queue_factory grpc_completion_queue_factory
The completion queue factory structure is opaque to the callers of grpc.
Definition: grpc_types.h:613
virtual gpr_timespec gpr_inf_future(gpr_clock_type type)=0
virtual void grpc_metadata_array_destroy(grpc_metadata_array *array)=0
virtual void gpr_cv_init(gpr_cv *cv)=0
virtual void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader)=0
virtual grpc_slice grpc_slice_new_with_user_data(void *p, size_t len, void(*destroy)(void *), void *user_data)=0
virtual grpc_slice grpc_slice_from_copied_buffer(const void *buffer, size_t length)=0
The result of an operation.
Definition: grpc_types.h:413
virtual grpc_slice grpc_empty_slice()=0
virtual void gpr_cv_signal(gpr_cv *cv)=0
#define GRPC_MUST_USE_RESULT
Definition: port_platform.h:390
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. ...
Definition: slice.h:91
virtual grpc_completion_queue * grpc_completion_queue_create_for_pluck(void *reserved)=0
virtual void grpc_call_unref(grpc_call *call)=0
virtual const Status & cancelled()=0
virtual void gpr_cv_broadcast(gpr_cv *cv)=0
Definition: grpc_types.h:56
Definition: grpc_types.h:427
virtual void gpr_mu_destroy(gpr_mu *mu)=0
Represents an expandable array of slices, to be interpreted as a single item.
Definition: slice.h:109
virtual void grpc_completion_queue_destroy(grpc_completion_queue *cq)=0
Definition: grpc_types.h:602
virtual int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline)=0
virtual void grpc_byte_buffer_destroy(grpc_byte_buffer *bb)=0
pthread_cond_t gpr_cv
Definition: sync_posix.h:42
virtual grpc_slice grpc_slice_from_static_buffer(const void *buffer, size_t length)=0
Definition: sync_windows.h:39
virtual grpc_completion_queue * grpc_completion_queue_create(const grpc_completion_queue_factory *factory, const grpc_completion_queue_attributes *attributes, void *reserved)=0
virtual void gpr_mu_lock(gpr_mu *mu)=0
virtual void assert_fail(const char *failed_assertion, const char *file, int line)=0
Upon a failed assertion, log the error.
CoreCodegenInterface * g_core_codegen_interface
Definition: call.h:64
virtual grpc_byte_buffer * grpc_raw_byte_buffer_create(grpc_slice *slice, size_t nslices)=0
virtual void gpr_cv_destroy(gpr_cv *cv)=0
virtual grpc_slice grpc_slice_ref(grpc_slice slice)=0
virtual void * grpc_call_arena_alloc(grpc_call *call, size_t length)=0
virtual grpc_slice grpc_slice_split_tail(grpc_slice *s, size_t split)=0
virtual void grpc_slice_unref(grpc_slice slice)=0
virtual void gpr_mu_init(gpr_mu *mu)=0
virtual void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice)=0
Interface between the codegen library and the minimal subset of core features required by the generat...
Definition: core_codegen_interface.h:56
Did it work? If it didn't, why?
Definition: status.h:45
Analogous to struct timespec.
Definition: gpr_types.h:62
virtual const Status & ok()=0
gpr_clock_type
The clocks we support.
Definition: gpr_types.h:46
virtual int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader, grpc_slice *slice)=0
virtual void grpc_metadata_array_init(grpc_metadata_array *array)=0
Definition: byte_buffer_reader.h:43
virtual void gpr_free(void *p)=0
virtual int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader, grpc_byte_buffer *buffer) GRPC_MUST_USE_RESULT=0
struct grpc_completion_queue grpc_completion_queue
Completion Queues enable notification of the completion of asynchronous actions.
Definition: grpc_types.h:72
virtual gpr_timespec gpr_time_0(gpr_clock_type type)=0
virtual grpc_slice grpc_slice_split_head(grpc_slice *s, size_t split)=0
virtual grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag, gpr_timespec deadline, void *reserved)=0
virtual grpc_completion_queue * grpc_completion_queue_create_for_next(void *reserved)=0
virtual void * gpr_malloc(size_t size)=0