GRPC C++  1.4.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, 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_H
35 #define GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H
36 
37 // This file should be compiled as part of grpc++.
38 
40 #include <grpc/byte_buffer.h>
41 #include <grpc/grpc.h>
43 
44 namespace grpc {
45 
47 class CoreCodegen final : public CoreCodegenInterface {
48  private:
49  virtual const grpc_completion_queue_factory*
50  grpc_completion_queue_factory_lookup(
51  const grpc_completion_queue_attributes* attributes) override;
52  virtual grpc_completion_queue* grpc_completion_queue_create(
53  const grpc_completion_queue_factory* factory,
54  const grpc_completion_queue_attributes* attributes,
55  void* reserved) override;
56  grpc_completion_queue* grpc_completion_queue_create_for_next(
57  void* reserved) override;
58  grpc_completion_queue* grpc_completion_queue_create_for_pluck(
59  void* reserved) override;
60  void grpc_completion_queue_destroy(grpc_completion_queue* cq) override;
61  grpc_event grpc_completion_queue_pluck(grpc_completion_queue* cq, void* tag,
62  gpr_timespec deadline,
63  void* reserved) override;
64 
65  void* gpr_malloc(size_t size) override;
66  void gpr_free(void* p) override;
67 
68  void gpr_mu_init(gpr_mu* mu) override;
69  void gpr_mu_destroy(gpr_mu* mu) override;
70  void gpr_mu_lock(gpr_mu* mu) override;
71  void gpr_mu_unlock(gpr_mu* mu) override;
72  void gpr_cv_init(gpr_cv* cv) override;
73  void gpr_cv_destroy(gpr_cv* cv) override;
74  int gpr_cv_wait(gpr_cv* cv, gpr_mu* mu, gpr_timespec abs_deadline) override;
75  void gpr_cv_signal(gpr_cv* cv) override;
76  void gpr_cv_broadcast(gpr_cv* cv) override;
77 
78  void grpc_call_ref(grpc_call* call) override;
79  void grpc_call_unref(grpc_call* call) override;
80  virtual void* grpc_call_arena_alloc(grpc_call* call, size_t length) override;
81 
82  void grpc_byte_buffer_destroy(grpc_byte_buffer* bb) override;
83 
84  int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader* reader,
85  grpc_byte_buffer* buffer) override;
86  void grpc_byte_buffer_reader_destroy(
87  grpc_byte_buffer_reader* reader) override;
88  int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader,
89  grpc_slice* slice) override;
90 
91  grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slice,
92  size_t nslices) override;
93  grpc_slice grpc_slice_new_with_user_data(void* p, size_t len,
94  void (*destroy)(void*),
95  void* user_data) override;
96  grpc_slice grpc_empty_slice() override;
97  grpc_slice grpc_slice_malloc(size_t length) override;
98  void grpc_slice_unref(grpc_slice slice) override;
99  grpc_slice grpc_slice_ref(grpc_slice slice) override;
100  grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) override;
101  grpc_slice grpc_slice_split_head(grpc_slice* s, size_t split) override;
102  void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice) override;
103  void grpc_slice_buffer_pop(grpc_slice_buffer* sb) override;
104  grpc_slice grpc_slice_from_static_buffer(const void* buffer,
105  size_t length) override;
106  grpc_slice grpc_slice_from_copied_buffer(const void* buffer,
107  size_t length) override;
108  void grpc_metadata_array_init(grpc_metadata_array* array) override;
109  void grpc_metadata_array_destroy(grpc_metadata_array* array) override;
110 
111  gpr_timespec gpr_inf_future(gpr_clock_type type) override;
112  gpr_timespec gpr_time_0(gpr_clock_type type) override;
113 
114  virtual const Status& ok() override;
115  virtual const Status& cancelled() override;
116 
117  void assert_fail(const char* failed_assertion, const char* file,
118  int line) override;
119 };
120 
121 } // namespace grpc
122 
123 #endif // GRPCXX_IMPL_CODEGEN_CORE_CODEGEN_H
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:86
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
The result of an operation.
Definition: grpc_types.h:413
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. ...
Definition: slice.h:91
Definition: grpc_types.h:56
Definition: grpc_types.h:427
Represents an expandable array of slices, to be interpreted as a single item.
Definition: slice.h:109
Definition: grpc_types.h:602
pthread_cond_t gpr_cv
Definition: sync_posix.h:42
Definition: sync_windows.h:39
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
gpr_clock_type
The clocks we support.
Definition: gpr_types.h:46
Definition: byte_buffer_reader.h:43
Implementation of the core codegen interface.
Definition: core_codegen.h:47
struct grpc_completion_queue grpc_completion_queue
Completion Queues enable notification of the completion of asynchronous actions.
Definition: grpc_types.h:72