Debian Codegraph @

test/core/util/passthru_endpoint.h

raw
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 PASSTHRU_ENDPOINT_H
20 #define PASSTHRU_ENDPOINT_H
21
22 #include <stdint.h>
23
24 #include <vector>
25
26 #include <grpc/support/atm.h>
27 #include <grpc/support/sync.h>
28
29 #include "src/core/lib/iomgr/endpoint.h"
30
31 /* The struct is refcounted, always use grpc_passthru_endpoint_stats_create and
32 * grpc_passthru_endpoint_stats_destroy, rather then embedding it in your
33 * objects by value. */
34 typedef struct {
35 gpr_refcount refs;
36 gpr_atm num_writes;
37 } grpc_passthru_endpoint_stats;
38
39 typedef struct {
40 uint64_t wait_ms;
41 uint64_t add_n_writable_bytes;
42 uint64_t add_n_readable_bytes;
43 } grpc_passthru_endpoint_channel_action;
44
45 void grpc_passthru_endpoint_create(grpc_endpoint** client,
46 grpc_endpoint** server,
47 grpc_passthru_endpoint_stats* stats,
48 bool simulate_channel_actions = false);
49
50 grpc_passthru_endpoint_stats* grpc_passthru_endpoint_stats_create();
51
52 void grpc_passthru_endpoint_stats_destroy(grpc_passthru_endpoint_stats* stats);
53
54 void start_scheduling_grpc_passthru_endpoint_channel_effects(
55 grpc_endpoint* ep,
56 const std::vector<grpc_passthru_endpoint_channel_action>& actions);
57
58 #endif // PASSTHRU_ENDPOINT_H