| 1 |
/* |
| 2 |
* |
| 3 |
* Copyright 2015 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 GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H |
| 20 |
#define GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H |
| 21 |
|
| 22 |
#include <grpc/support/port_platform.h> |
| 23 |
|
| 24 |
#include <stddef.h> |
| 25 |
|
| 26 |
#include "absl/strings/string_view.h" |
| 27 |
|
| 28 |
#include "src/core/lib/iomgr/closure.h" |
| 29 |
#include "src/core/lib/iomgr/endpoint.h" |
| 30 |
#include "src/core/lib/iomgr/iomgr_fwd.h" |
| 31 |
#include "src/core/lib/promise/arena_promise.h" |
| 32 |
#include "src/core/lib/resource_quota/arena.h" |
| 33 |
#include "src/core/lib/transport/transport.h" |
| 34 |
#include "src/core/lib/transport/transport_fwd.h" |
| 35 |
|
| 36 |
typedef struct grpc_transport_vtable { |
| 37 |
/* Memory required for a single stream element - this is allocated by upper |
| 38 |
layers and initialized by the transport */ |
| 39 |
size_t sizeof_stream; /* = sizeof(transport stream) */ |
| 40 |
|
| 41 |
/* name of this transport implementation */ |
| 42 |
const char* name; |
| 43 |
|
| 44 |
/* implementation of grpc_transport_init_stream */ |
| 45 |
int (*init_stream)(grpc_transport* self, grpc_stream* stream, |
| 46 |
grpc_stream_refcount* refcount, const void* server_data, |
| 47 |
grpc_core::Arena* arena); |
| 48 |
|
| 49 |
/* Create a promise to execute one client call. |
| 50 |
If this is non-null, it may be used in preference to |
| 51 |
perform_stream_op. |
| 52 |
If this is used in preference to perform_stream_op, the |
| 53 |
following can be omitted also: |
| 54 |
- calling init_stream, destroy_stream, set_pollset, set_pollset_set |
| 55 |
- allocation of memory for call data (sizeof_stream may be ignored) |
| 56 |
There is an on-going migration to move all filters to providing this, and |
| 57 |
then to drop perform_stream_op. */ |
| 58 |
grpc_core::ArenaPromise<grpc_core::ServerMetadataHandle> (*make_call_promise)( |
| 59 |
grpc_transport* self, grpc_core::CallArgs call_args); |
| 60 |
|
| 61 |
/* implementation of grpc_transport_set_pollset */ |
| 62 |
void (*set_pollset)(grpc_transport* self, grpc_stream* stream, |
| 63 |
grpc_pollset* pollset); |
| 64 |
|
| 65 |
/* implementation of grpc_transport_set_pollset */ |
| 66 |
void (*set_pollset_set)(grpc_transport* self, grpc_stream* stream, |
| 67 |
grpc_pollset_set* pollset_set); |
| 68 |
|
| 69 |
/* implementation of grpc_transport_perform_stream_op */ |
| 70 |
void (*perform_stream_op)(grpc_transport* self, grpc_stream* stream, |
| 71 |
grpc_transport_stream_op_batch* op); |
| 72 |
|
| 73 |
/* implementation of grpc_transport_perform_op */ |
| 74 |
void (*perform_op)(grpc_transport* self, grpc_transport_op* op); |
| 75 |
|
| 76 |
/* implementation of grpc_transport_destroy_stream */ |
| 77 |
void (*destroy_stream)(grpc_transport* self, grpc_stream* stream, |
| 78 |
grpc_closure* then_schedule_closure); |
| 79 |
|
| 80 |
/* implementation of grpc_transport_destroy */ |
| 81 |
void (*destroy)(grpc_transport* self); |
| 82 |
|
| 83 |
/* implementation of grpc_transport_get_endpoint */ |
| 84 |
grpc_endpoint* (*get_endpoint)(grpc_transport* self); |
| 85 |
} grpc_transport_vtable; |
| 86 |
|
| 87 |
/* an instance of a grpc transport */ |
| 88 |
struct grpc_transport { |
| 89 |
struct RawPointerChannelArgTag {}; |
| 90 |
static absl::string_view ChannelArgName() { return GRPC_ARG_TRANSPORT; } |
| 91 |
/* pointer to a vtable defining operations on this transport */ |
| 92 |
const grpc_transport_vtable* vtable; |
| 93 |
}; |
| 94 |
|
| 95 |
#endif /* GRPC_CORE_LIB_TRANSPORT_TRANSPORT_IMPL_H */ |