GRPC C++  1.8.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H
20 #define GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H
21 
22 // This file should be compiled as part of grpc++.
23 
25 #include <grpc/byte_buffer.h>
26 #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_destroy(grpc_completion_queue* cq) override;
46  grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag,
47  gpr_timespec deadline,
48  void* reserved) override;
49 
50  void* gpr_malloc(size_t size) override;
51  void gpr_free(void* p) override;
52 
53  void grpc_init() override;
54  void grpc_shutdown() override;
55 
56  void gpr_mu_init(gpr_mu* mu) override;
57  void gpr_mu_destroy(gpr_mu* mu) override;
58  void gpr_mu_lock(gpr_mu* mu) override;
59  void gpr_mu_unlock(gpr_mu* mu) override;
60  void gpr_cv_init(gpr_cv* cv) override;
61  void gpr_cv_destroy(gpr_cv* cv) override;
62  int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) override;
63  void gpr_cv_signal(gpr_cv* cv) override;
64  void gpr_cv_broadcast(gpr_cv* cv) override;
65 
66  grpc_call_error grpc_call_cancel_with_status(grpc_call* call,
67  grpc_status_code status,
68  const char* description,
69  void* reserved) override;
70  void grpc_call_ref(grpc_call* call) override;
71  void grpc_call_unref(grpc_call* call) override;
72  virtual void* grpc_call_arena_alloc(grpc_call* call, size_t length) override;
73 
74  grpc_byte_buffer* grpc_byte_buffer_copy(grpc_byte_buffer* bb) override;
75  void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) override;
76 
77  int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
78  grpc_byte_buffer* buffer) override;
79  void grpc_byte_buffer_reader_destroy(
80  grpc_byte_buffer_reader* reader) override;
81  int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader,
82  grpc_slice* slice) override;
83 
84  grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slice,
85  size_t nslices) override;
86  grpc_slice grpc_slice_new_with_user_data(void* p, size_t len,
87  void (*destroy)(void*),
88  void* user_data) override;
89  grpc_slice grpc_empty_slice() override;
90  grpc_slice grpc_slice_malloc(size_t length) override;
91  void grpc_slice_unref(grpc_slice slice) override;
92  grpc_slice grpc_slice_ref(grpc_slice slice) override;
93  grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) override;
94  grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split) override;
95  grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end) override;
96  void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice) override;
97  void grpc_slice_buffer_pop(grpc_slice_buffer* sb) override;
98  grpc_slice grpc_slice_from_static_buffer(const void* buffer,
99  size_t length) override;
100  grpc_slice grpc_slice_from_copied_buffer(const void* buffer,
101  size_t length) override;
102  void grpc_metadata_array_init(grpc_metadata_array* array) override;
103  void grpc_metadata_array_destroy(grpc_metadata_array* array) override;
104 
105  gpr_timespec gpr_inf_future(gpr_clock_type type) override;
106  gpr_timespec gpr_time_0(gpr_clock_type type) override;
107 
108  virtual const Status& ok() override;
109  virtual const Status& cancelled() override;
110 
111  void assert_fail(const char* failed_assertion, const char* file,
112  int line) override;
113 };
114 
115 } // namespace grpc
116 
117 #endif // GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:71
grpc_status_code
Definition: status.h:26
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:636
The result of an operation.
Definition: grpc_types.h:423
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. ...
Definition: slice.h:81
Definition: grpc_types.h:41
Definition: grpc_types.h:437
Represents an expandable array of slices, to be interpreted as a single item.
Definition: slice.h:99
Definition: grpc_types.h:625
grpc_call_error
Result of a grpc call.
Definition: grpc_types.h:316
pthread_cond_t gpr_cv
Definition: sync_posix.h:27
Definition: sync_windows.h:24
Interface between the codegen library and the minimal subset of core features required by the generat...
Definition: core_codegen_interface.h:41
Did it work? If it didn't, why?
Definition: status.h:30
Analogous to struct timespec.
Definition: gpr_types.h:47
gpr_clock_type
The clocks we support.
Definition: gpr_types.h:31
Definition: byte_buffer_reader.h:28
Implementation of the core codegen interface.
Definition: core_codegen.h:32
struct grpc_completion_queue grpc_completion_queue
Completion Queues enable notification of the completion of asynchronous actions.
Definition: grpc_types.h:57