GRPC C++  1.3.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 
63  void* reserved) = 0;
66  void* tag,
67  gpr_timespec deadline,
68  void* reserved) = 0;
69 
70  virtual void* gpr_malloc(size_t size) = 0;
71  virtual void gpr_free(void* p) = 0;
72 
73  virtual void gpr_mu_init(gpr_mu* mu) = 0;
74  virtual void gpr_mu_destroy(gpr_mu* mu) = 0;
75  virtual void gpr_mu_lock(gpr_mu* mu) = 0;
76  virtual void gpr_mu_unlock(gpr_mu* mu) = 0;
77  virtual void gpr_cv_init(gpr_cv* cv) = 0;
78  virtual void gpr_cv_destroy(gpr_cv* cv) = 0;
79  virtual int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu,
80  gpr_timespec abs_deadline) = 0;
81  virtual void gpr_cv_signal(gpr_cv* cv) = 0;
82  virtual void gpr_cv_broadcast(gpr_cv* cv) = 0;
83 
84  virtual void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) = 0;
85 
87  grpc_byte_buffer* buffer)
90  grpc_byte_buffer_reader* reader) = 0;
92  grpc_slice* slice) = 0;
93 
95  size_t nslices) = 0;
96 
97  virtual grpc_slice grpc_empty_slice() = 0;
98  virtual grpc_slice grpc_slice_malloc(size_t length) = 0;
99  virtual void grpc_slice_unref(grpc_slice slice) = 0;
100  virtual grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) = 0;
101  virtual void grpc_slice_buffer_add(grpc_slice_buffer* sb,
102  grpc_slice slice) = 0;
103  virtual void grpc_slice_buffer_pop(grpc_slice_buffer* sb) = 0;
104  virtual grpc_slice grpc_slice_from_static_buffer(const void* buffer,
105  size_t length) = 0;
106  virtual grpc_slice grpc_slice_from_copied_buffer(const void* buffer,
107  size_t length) = 0;
108 
109  virtual void grpc_metadata_array_init(grpc_metadata_array* array) = 0;
110  virtual void grpc_metadata_array_destroy(grpc_metadata_array* array) = 0;
111 
112  virtual const Status& ok() = 0;
113  virtual const Status& cancelled() = 0;
114 
115  virtual gpr_timespec gpr_inf_future(gpr_clock_type type) = 0;
116  virtual gpr_timespec gpr_time_0(gpr_clock_type type) = 0;
117 };
118 
120 
122 #define GPR_CODEGEN_ASSERT(x) \
123  do { \
124  if (!(x)) { \
125  grpc::g_core_codegen_interface->assert_fail(#x, __FILE__, __LINE__); \
126  } \
127  } while (0)
128 
129 } // namespace grpc
130 
131 #endif // GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_INTERFACE_H
virtual void grpc_slice_buffer_pop(grpc_slice_buffer *sb)=0
virtual void gpr_mu_unlock(gpr_mu *mu)=0
virtual grpc_slice grpc_slice_malloc(size_t length)=0
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_from_copied_buffer(const void *buffer, size_t length)=0
The result of an operation.
Definition: grpc_types.h:393
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:384
Definition: slice.h:90
virtual const Status & cancelled()=0
virtual void gpr_cv_broadcast(gpr_cv *cv)=0
Definition: grpc_types.h:55
Definition: grpc_types.h:404
virtual void gpr_mu_destroy(gpr_mu *mu)=0
Definition: slice.h:108
virtual void grpc_completion_queue_destroy(grpc_completion_queue *cq)=0
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 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:63
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_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
Definition: gpr_types.h:63
virtual const Status & ok()=0
gpr_clock_type
Definition: gpr_types.h:47
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:71
virtual gpr_timespec gpr_time_0(gpr_clock_type type)=0
virtual grpc_completion_queue * grpc_completion_queue_create(void *reserved)=0
virtual grpc_event grpc_completion_queue_pluck(grpc_completion_queue *cq, void *tag, gpr_timespec deadline, void *reserved)=0
virtual void * gpr_malloc(size_t size)=0