GRPC C++  1.30.0
core_codegen.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2016 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_H
20 #define GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_H
21 
22 // This file should be compiled as part of grpcpp.
23 
24 #include <grpc/byte_buffer.h>
25 #include <grpc/grpc.h>
28 
29 namespace grpc {
30 
32 class CoreCodegen final : public CoreCodegenInterface {
33  private:
34  virtual const grpc_completion_queue_factory*
35  grpc_completion_queue_factory_lookup(
36  const grpc_completion_queue_attributes* attributes) override;
37  virtual grpc_completion_queue* grpc_completion_queue_create(
38  const grpc_completion_queue_factory* factory,
39  const grpc_completion_queue_attributes* attributes,
40  void* reserved) override;
41  grpc_completion_queue* grpc_completion_queue_create_for_next(
42  void* reserved) override;
43  grpc_completion_queue* grpc_completion_queue_create_for_pluck(
44  void* reserved) override;
45  void grpc_completion_queue_shutdown(grpc_completion_queue* cq) override;
46  void grpc_completion_queue_destroy(grpc_completion_queue* cq) override;
47  grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag,
48  gpr_timespec deadline,
49  void* reserved) override;
50 
51  void* gpr_malloc(size_t size) override;
52  void gpr_free(void* p) override;
53 
54  void grpc_init() override;
55  void grpc_shutdown() override;
56 
57  void gpr_mu_init(gpr_mu* mu) override;
58  void gpr_mu_destroy(gpr_mu* mu) override;
59  void gpr_mu_lock(gpr_mu* mu) override;
60  void gpr_mu_unlock(gpr_mu* mu) override;
61  void gpr_cv_init(gpr_cv* cv) override;
62  void gpr_cv_destroy(gpr_cv* cv) override;
63  int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) override;
64  void gpr_cv_signal(gpr_cv* cv) override;
65  void gpr_cv_broadcast(gpr_cv* cv) override;
66 
67  grpc_call_error grpc_call_start_batch(grpc_call* call, const grpc_op* ops,
68  size_t nops, void* tag,
69  void* reserved) override;
70  grpc_call_error grpc_call_cancel_with_status(grpc_call* call,
71  grpc_status_code status,
72  const char* description,
73  void* reserved) override;
74  void grpc_call_ref(grpc_call* call) override;
75  void grpc_call_unref(grpc_call* call) override;
76  void* grpc_call_arena_alloc(grpc_call* call, size_t length) override;
77  const char* grpc_call_error_to_string(grpc_call_error error) override;
78 
79  grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb) override;
80  void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) override;
81  size_t grpc_byte_buffer_length(grpc_byte_buffer* bb) override;
82 
83  int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
84  grpc_byte_buffer* buffer) override;
85  void grpc_byte_buffer_reader_destroy(
86  grpc_byte_buffer_reader* reader) override;
87  int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader,
88  grpc_slice* slice) override;
89  int grpc_byte_buffer_reader_peek(grpc_byte_buffer_reader* reader,
90  grpc_slice** slice) override;
91 
92  grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slice,
93  size_t nslices) override;
94  grpc_slice grpc_slice_new_with_user_data(void* p, size_t len,
95  void (*destroy)(void*),
96  void* user_data) override;
97  grpc_slice grpc_slice_new_with_len(void* p, size_t len,
98  void (*destroy)(void*, size_t)) override;
99  grpc_slice grpc_empty_slice() override;
100  grpc_slice grpc_slice_malloc(size_t length) override;
101  void grpc_slice_unref(grpc_slice slice) override;
102  grpc_slice grpc_slice_ref(grpc_slice slice) override;
103  grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) override;
104  grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split) override;
105  grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end) override;
106  void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice) override;
107  void grpc_slice_buffer_pop(grpc_slice_buffer* sb) override;
108  grpc_slice grpc_slice_from_static_buffer(const void* buffer,
109  size_t length) override;
110  grpc_slice grpc_slice_from_copied_buffer(const void* buffer,
111  size_t length) override;
112  void grpc_metadata_array_init(grpc_metadata_array* array) override;
113  void grpc_metadata_array_destroy(grpc_metadata_array* array) override;
114 
115  gpr_timespec gpr_inf_future(gpr_clock_type type) override;
116  gpr_timespec gpr_time_0(gpr_clock_type type) override;
117 
118  virtual const Status& ok() override;
119  virtual const Status& cancelled() override;
120 
121  void assert_fail(const char* failed_assertion, const char* file,
122  int line) override;
123 };
124 
125 } // namespace grpc
126 
127 #endif // GRPCPP_IMPL_CODEGEN_CORE_CODEGEN_H
grpc_call_error
grpc_call_error
Result of a grpc call.
Definition: grpc_types.h:424
grpc_status_code
grpc_status_code
Definition: status.h:26
grpc
This header provides an object that reads bytes directly from a grpc::ByteBuffer, via the ZeroCopyInp...
Definition: alarm.h:24
grpc::CoreCodegen
Implementation of the core codegen interface.
Definition: core_codegen.h:32
grpc_metadata_array
Definition: grpc_types.h:546
gpr_cv
pthread_cond_t gpr_cv
Definition: sync_posix.h:46
core_codegen_interface.h
grpc_types.h
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:31
grpc_event
The result of an operation.
Definition: grpc_types.h:531
grpc.h
grpc_call
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:70
grpc_byte_buffer
Definition: grpc_types.h:40
grpc_op
Operation data: one field for each op type (except SEND_CLOSE_FROM_CLIENT which has no arguments)
Definition: grpc_types.h:607
grpc_slice
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60
grpc_completion_queue_attributes
Definition: grpc_types.h:759
grpc::CoreCodegenInterface
Interface between the codegen library and the minimal subset of core features required by the generat...
Definition: core_codegen_interface.h:38
grpc_completion_queue_factory
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:779
byte_buffer.h
grpc_completion_queue
struct grpc_completion_queue grpc_completion_queue
Completion Queues enable notification of the completion of asynchronous actions.
Definition: grpc_types.h:56
grpc_slice_buffer
Represents an expandable array of slices, to be interpreted as a single item.
Definition: slice.h:78
gpr_mu
Definition: sync_windows.h:26
gpr_timespec
Analogous to struct timespec.
Definition: gpr_types.h:47
grpc_byte_buffer_reader
Definition: byte_buffer_reader.h:28
gpr_clock_type
gpr_clock_type
The clocks we support.
Definition: gpr_types.h:31