grpc 1.49.1 → 1.50.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +54 -153
- data/include/grpc/event_engine/endpoint_config.h +11 -5
- data/include/grpc/event_engine/event_engine.h +1 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +19 -28
- data/include/grpc/impl/codegen/atm_gcc_sync.h +0 -2
- data/include/grpc/impl/codegen/atm_windows.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +6 -0
- data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +3 -3
- data/src/core/ext/filters/client_channel/backup_poller.cc +4 -6
- data/src/core/ext/filters/client_channel/client_channel.cc +33 -22
- data/src/core/ext/filters/client_channel/client_channel.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +0 -16
- data/src/core/ext/filters/client_channel/http_proxy.cc +12 -19
- data/src/core/ext/filters/client_channel/http_proxy.h +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -4
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +5 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +0 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +112 -96
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +20 -11
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +106 -108
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +16 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +20 -13
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +165 -257
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +218 -231
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -6
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +389 -444
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +16 -16
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +8 -13
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +84 -96
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +38 -37
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +106 -186
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +106 -93
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +170 -218
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +13 -15
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +84 -37
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +11 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +5 -4
- data/src/core/ext/filters/client_channel/retry_filter.cc +25 -29
- data/src/core/ext/filters/client_channel/subchannel.cc +38 -33
- data/src/core/ext/filters/client_channel/subchannel.h +12 -3
- data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +1 -2
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +23 -16
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +8 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +1 -2
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -4
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +0 -2
- data/src/core/ext/filters/http/server/http_server_filter.cc +1 -2
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +12 -8
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +32 -26
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +25 -130
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +287 -0
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +1018 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +83 -51
- data/src/core/ext/transport/chttp2/transport/flow_control.h +11 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -20
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +28 -28
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +1 -10
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +11 -6
- data/src/core/ext/transport/chttp2/transport/internal.h +2 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +44 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -14
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -3
- data/src/core/ext/xds/certificate_provider_store.cc +63 -3
- data/src/core/ext/xds/certificate_provider_store.h +9 -1
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +5 -5
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +1 -1
- data/src/core/ext/xds/xds_api.cc +21 -17
- data/src/core/ext/xds/xds_api.h +7 -0
- data/src/core/ext/xds/xds_bootstrap.cc +5 -537
- data/src/core/ext/xds/xds_bootstrap.h +39 -111
- data/src/core/ext/xds/xds_bootstrap_grpc.cc +370 -0
- data/src/core/ext/xds/xds_bootstrap_grpc.h +169 -0
- data/src/core/ext/xds/xds_client.cc +219 -145
- data/src/core/ext/xds/xds_client.h +19 -17
- data/src/core/ext/xds/xds_client_grpc.cc +18 -80
- data/src/core/ext/xds/xds_client_grpc.h +2 -25
- data/src/core/ext/xds/xds_client_stats.cc +4 -4
- data/src/core/ext/xds/xds_cluster.cc +87 -79
- data/src/core/ext/xds/xds_cluster.h +5 -5
- data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +3 -1
- data/src/core/ext/xds/xds_common_types.cc +13 -5
- data/src/core/ext/xds/xds_endpoint.cc +8 -6
- data/src/core/ext/xds/xds_endpoint.h +3 -4
- data/src/core/ext/xds/xds_lb_policy_registry.cc +4 -2
- data/src/core/ext/xds/xds_listener.cc +25 -20
- data/src/core/ext/xds/xds_listener.h +3 -4
- data/src/core/ext/xds/xds_resource_type.h +11 -8
- data/src/core/ext/xds/xds_route_config.cc +15 -16
- data/src/core/ext/xds/xds_route_config.h +3 -3
- data/src/core/ext/xds/xds_server_config_fetcher.cc +7 -5
- data/src/core/ext/xds/xds_transport_grpc.cc +15 -7
- data/src/core/lib/backoff/backoff.cc +2 -4
- data/src/core/lib/channel/call_finalization.h +1 -3
- data/src/core/lib/channel/channel_args.h +114 -14
- data/src/core/lib/channel/channel_trace.cc +3 -4
- data/src/core/lib/channel/promise_based_filter.cc +18 -19
- data/src/core/lib/channel/status_util.cc +27 -0
- data/src/core/lib/channel/status_util.h +10 -0
- data/src/core/lib/config/core_configuration.cc +5 -1
- data/src/core/lib/config/core_configuration.h +33 -0
- data/src/core/lib/debug/stats.cc +26 -30
- data/src/core/lib/debug/stats.h +2 -12
- data/src/core/lib/debug/stats_data.cc +118 -614
- data/src/core/lib/debug/stats_data.h +67 -465
- data/src/core/lib/debug/trace.cc +0 -2
- data/src/core/lib/event_engine/channel_args_endpoint_config.cc +12 -20
- data/src/core/lib/event_engine/channel_args_endpoint_config.h +13 -7
- data/src/core/lib/event_engine/forkable.cc +1 -1
- data/src/core/lib/event_engine/poller.h +14 -12
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +53 -32
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +23 -1
- data/src/core/lib/event_engine/thread_pool.cc +131 -94
- data/src/core/lib/event_engine/thread_pool.h +56 -23
- data/src/core/lib/event_engine/time_util.cc +30 -0
- data/src/core/lib/event_engine/time_util.h +32 -0
- data/src/core/lib/event_engine/utils.cc +0 -5
- data/src/core/lib/event_engine/utils.h +0 -4
- data/src/core/lib/event_engine/windows/iocp.cc +13 -7
- data/src/core/lib/event_engine/windows/iocp.h +2 -1
- data/src/core/lib/event_engine/windows/win_socket.cc +1 -1
- data/src/core/lib/experiments/config.cc +146 -0
- data/src/core/lib/experiments/config.h +43 -0
- data/src/core/lib/experiments/experiments.cc +75 -0
- data/src/core/lib/experiments/experiments.h +56 -0
- data/src/core/lib/gpr/alloc.cc +1 -9
- data/src/core/lib/gpr/log_windows.cc +0 -1
- data/src/core/lib/gpr/string_util_windows.cc +3 -30
- data/src/core/lib/gpr/sync_abseil.cc +0 -14
- data/src/core/lib/gpr/sync_posix.cc +0 -14
- data/src/core/lib/gpr/time_posix.cc +0 -6
- data/src/core/lib/gpr/time_precise.h +1 -1
- data/src/core/lib/gpr/tmpfile_windows.cc +5 -7
- data/src/core/lib/gpr/useful.h +11 -0
- data/src/core/lib/{gpr → gprpp}/env.h +25 -12
- data/src/core/lib/{gpr → gprpp}/env_linux.cc +20 -15
- data/src/core/lib/{gpr → gprpp}/env_posix.cc +11 -10
- data/src/core/lib/gprpp/env_windows.cc +56 -0
- data/src/core/lib/gprpp/fork.cc +14 -22
- data/src/core/lib/gprpp/fork.h +0 -8
- data/src/core/lib/gprpp/global_config_env.cc +7 -6
- data/src/core/lib/gprpp/notification.h +67 -0
- data/src/core/lib/gprpp/packed_table.h +40 -0
- data/src/core/lib/gprpp/ref_counted_ptr.h +20 -33
- data/src/core/lib/gprpp/sorted_pack.h +98 -0
- data/src/core/lib/gprpp/status_helper.h +6 -0
- data/src/core/lib/gprpp/table.h +9 -1
- data/src/core/lib/gprpp/tchar.cc +49 -0
- data/src/core/lib/gprpp/tchar.h +33 -0
- data/src/core/lib/gprpp/time.cc +21 -0
- data/src/core/lib/gprpp/time.h +55 -0
- data/src/core/lib/gprpp/validation_errors.cc +61 -0
- data/src/core/lib/gprpp/validation_errors.h +110 -0
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper.h +3 -3
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper_registry.cc +14 -36
- data/src/core/lib/handshaker/proxy_mapper_registry.h +75 -0
- data/src/core/lib/iomgr/call_combiner.cc +0 -8
- data/src/core/lib/iomgr/closure.h +0 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +14 -10
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +1 -38
- data/src/core/lib/iomgr/ev_poll_posix.cc +2 -17
- data/src/core/lib/iomgr/exec_ctx.cc +0 -10
- data/src/core/lib/iomgr/exec_ctx.h +7 -31
- data/src/core/lib/iomgr/iocp_windows.cc +1 -2
- data/src/core/lib/iomgr/iomgr.cc +6 -8
- data/src/core/lib/iomgr/iomgr_fwd.h +1 -0
- data/src/core/lib/iomgr/pollset.h +1 -1
- data/src/core/lib/iomgr/pollset_set.h +0 -1
- data/src/core/lib/iomgr/resolve_address.h +1 -0
- data/src/core/lib/iomgr/resolve_address_impl.h +1 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +1 -0
- data/src/core/lib/iomgr/resolve_address_windows.cc +1 -0
- data/src/core/lib/iomgr/sockaddr_utils_posix.cc +2 -1
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +12 -34
- data/src/core/lib/iomgr/socket_utils_posix.cc +83 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +98 -6
- data/src/core/lib/iomgr/tcp_client.cc +6 -7
- data/src/core/lib/iomgr/tcp_client.h +11 -11
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +6 -6
- data/src/core/lib/iomgr/tcp_client_posix.cc +33 -29
- data/src/core/lib/iomgr/tcp_client_posix.h +12 -9
- data/src/core/lib/iomgr/tcp_client_windows.cc +6 -6
- data/src/core/lib/iomgr/tcp_posix.cc +131 -114
- data/src/core/lib/iomgr/tcp_posix.h +3 -1
- data/src/core/lib/iomgr/tcp_server.cc +5 -4
- data/src/core/lib/iomgr/tcp_server.h +9 -6
- data/src/core/lib/iomgr/tcp_server_posix.cc +17 -28
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +3 -3
- data/src/core/lib/iomgr/tcp_server_windows.cc +6 -7
- data/src/core/lib/iomgr/tcp_windows.cc +0 -1
- data/src/core/lib/iomgr/tcp_windows.h +0 -1
- data/src/core/lib/iomgr/timer_generic.cc +4 -4
- data/src/core/lib/iomgr/timer_manager.cc +1 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +0 -2
- data/src/core/lib/json/json_object_loader.cc +21 -52
- data/src/core/lib/json/json_object_loader.h +56 -76
- data/src/core/lib/json/json_util.cc +2 -1
- data/src/core/lib/load_balancing/lb_policy.h +5 -5
- data/src/core/lib/load_balancing/lb_policy_registry.cc +29 -55
- data/src/core/lib/load_balancing/lb_policy_registry.h +23 -11
- data/src/core/lib/promise/activity.h +2 -3
- data/src/core/lib/promise/context.h +1 -1
- data/src/core/lib/promise/sleep.cc +16 -4
- data/src/core/lib/promise/sleep.h +8 -2
- data/src/core/lib/resolver/resolver.h +13 -3
- data/src/core/lib/resource_quota/api.cc +9 -0
- data/src/core/lib/resource_quota/api.h +6 -0
- data/src/core/lib/resource_quota/arena.cc +1 -3
- data/src/core/lib/resource_quota/memory_quota.cc +8 -24
- data/src/core/lib/resource_quota/memory_quota.h +6 -19
- data/src/core/lib/resource_quota/periodic_update.cc +2 -3
- data/src/core/{ext/xds → lib/security/certificate_provider}/certificate_provider_factory.h +3 -3
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +60 -0
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +70 -0
- data/src/core/lib/security/credentials/channel_creds_registry_init.cc +1 -0
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +15 -16
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +2 -1
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +5 -8
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +6 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -3
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +4 -2
- data/src/core/lib/security/credentials/tls/tls_utils.cc +3 -1
- data/src/core/lib/security/transport/client_auth_filter.cc +12 -1
- data/src/core/lib/security/transport/secure_endpoint.cc +0 -4
- data/src/core/lib/surface/call.cc +1 -11
- data/src/core/lib/surface/channel.cc +3 -2
- data/src/core/lib/surface/completion_queue.cc +16 -28
- data/src/core/lib/surface/completion_queue.h +1 -1
- data/src/core/lib/surface/completion_queue_factory.cc +5 -0
- data/src/core/lib/surface/init.cc +16 -11
- data/src/core/lib/surface/init_internally.cc +24 -0
- data/src/core/lib/surface/init_internally.h +28 -0
- data/src/core/lib/surface/server.cc +1 -7
- data/src/core/lib/surface/server.h +4 -6
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +1 -3
- data/src/core/lib/transport/metadata_batch.cc +2 -3
- data/src/core/lib/transport/metadata_batch.h +9 -7
- data/src/core/lib/transport/parsed_metadata.h +4 -2
- data/src/core/lib/transport/status_conversion.cc +1 -3
- data/src/core/lib/transport/tcp_connect_handshaker.cc +9 -5
- data/src/core/lib/transport/transport.h +0 -1
- data/src/core/lib/transport/transport_impl.h +0 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +23 -46
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +13 -25
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/channel_spec.rb +5 -0
- data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
- data/src/ruby/spec/user_agent_spec.rb +1 -1
- metadata +33 -19
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +0 -56
- data/src/core/ext/xds/certificate_provider_registry.cc +0 -103
- data/src/core/ext/xds/certificate_provider_registry.h +0 -59
- data/src/core/lib/event_engine/promise.h +0 -78
- data/src/core/lib/gpr/env_windows.cc +0 -74
- data/src/core/lib/gpr/string_windows.h +0 -32
- data/src/core/lib/profiling/basic_timers.cc +0 -295
- data/src/core/lib/profiling/stap_timers.cc +0 -50
- data/src/core/lib/profiling/timers.h +0 -94
@@ -29,14 +29,6 @@
|
|
29
29
|
#include <grpc/support/sync.h>
|
30
30
|
#include <grpc/support/time.h>
|
31
31
|
|
32
|
-
#include "src/core/lib/profiling/timers.h"
|
33
|
-
|
34
|
-
#ifdef GPR_LOW_LEVEL_COUNTERS
|
35
|
-
gpr_atm gpr_mu_locks = 0;
|
36
|
-
gpr_atm gpr_counter_atm_cas = 0;
|
37
|
-
gpr_atm gpr_counter_atm_add = 0;
|
38
|
-
#endif
|
39
|
-
|
40
32
|
void gpr_mu_init(gpr_mu* mu) {
|
41
33
|
#ifdef GRPC_ASAN_ENABLED
|
42
34
|
GPR_ASSERT(pthread_mutex_init(&mu->mutex, nullptr) == 0);
|
@@ -57,10 +49,6 @@ void gpr_mu_destroy(gpr_mu* mu) {
|
|
57
49
|
}
|
58
50
|
|
59
51
|
void gpr_mu_lock(gpr_mu* mu) {
|
60
|
-
#ifdef GPR_LOW_LEVEL_COUNTERS
|
61
|
-
GPR_ATM_INC_COUNTER(gpr_mu_locks);
|
62
|
-
#endif
|
63
|
-
GPR_TIMER_SCOPE("gpr_mu_lock", 0);
|
64
52
|
#ifdef GRPC_ASAN_ENABLED
|
65
53
|
GPR_ASSERT(pthread_mutex_lock(&mu->mutex) == 0);
|
66
54
|
#else
|
@@ -69,7 +57,6 @@ void gpr_mu_lock(gpr_mu* mu) {
|
|
69
57
|
}
|
70
58
|
|
71
59
|
void gpr_mu_unlock(gpr_mu* mu) {
|
72
|
-
GPR_TIMER_SCOPE("gpr_mu_unlock", 0);
|
73
60
|
#ifdef GRPC_ASAN_ENABLED
|
74
61
|
GPR_ASSERT(pthread_mutex_unlock(&mu->mutex) == 0);
|
75
62
|
#else
|
@@ -78,7 +65,6 @@ void gpr_mu_unlock(gpr_mu* mu) {
|
|
78
65
|
}
|
79
66
|
|
80
67
|
int gpr_mu_trylock(gpr_mu* mu) {
|
81
|
-
GPR_TIMER_SCOPE("gpr_mu_trylock", 0);
|
82
68
|
int err = 0;
|
83
69
|
#ifdef GRPC_ASAN_ENABLED
|
84
70
|
err = pthread_mutex_trylock(&mu->mutex);
|
@@ -140,13 +140,7 @@ static gpr_timespec now_impl(gpr_clock_type clock) {
|
|
140
140
|
|
141
141
|
gpr_timespec (*gpr_now_impl)(gpr_clock_type clock_type) = now_impl;
|
142
142
|
|
143
|
-
#ifdef GPR_LOW_LEVEL_COUNTERS
|
144
|
-
gpr_atm gpr_now_call_count;
|
145
|
-
#endif
|
146
143
|
gpr_timespec gpr_now(gpr_clock_type clock_type) {
|
147
|
-
#ifdef GPR_LOW_LEVEL_COUNTERS
|
148
|
-
__atomic_fetch_add(&gpr_now_call_count, 1, __ATOMIC_RELAXED);
|
149
|
-
#endif
|
150
144
|
// validate clock type
|
151
145
|
GPR_ASSERT(clock_type == GPR_CLOCK_MONOTONIC ||
|
152
146
|
clock_type == GPR_CLOCK_REALTIME ||
|
@@ -28,7 +28,7 @@
|
|
28
28
|
// low as a usec. Use other clock sources or gpr_precise_clock_now(),
|
29
29
|
// where you need high resolution clocks.
|
30
30
|
//
|
31
|
-
// Using gpr_get_cycle_counter() is preferred to using
|
31
|
+
// Using gpr_get_cycle_counter() is preferred to using Timestamp::Now()
|
32
32
|
// whenever possible.
|
33
33
|
|
34
34
|
#if GPR_CYCLE_COUNTER_CUSTOM
|
@@ -29,12 +29,11 @@
|
|
29
29
|
#include <grpc/support/log.h>
|
30
30
|
#include <grpc/support/string_util.h>
|
31
31
|
|
32
|
-
#include "src/core/lib/gpr/string_windows.h"
|
33
32
|
#include "src/core/lib/gpr/tmpfile.h"
|
33
|
+
#include "src/core/lib/gprpp/tchar.h"
|
34
34
|
|
35
35
|
FILE* gpr_tmpfile(const char* prefix, char** tmp_filename_out) {
|
36
36
|
FILE* result = NULL;
|
37
|
-
LPTSTR template_string = NULL;
|
38
37
|
TCHAR tmp_path[MAX_PATH];
|
39
38
|
TCHAR tmp_filename[MAX_PATH];
|
40
39
|
DWORD status;
|
@@ -43,15 +42,14 @@ FILE* gpr_tmpfile(const char* prefix, char** tmp_filename_out) {
|
|
43
42
|
if (tmp_filename_out != NULL) *tmp_filename_out = NULL;
|
44
43
|
|
45
44
|
/* Convert our prefix to TCHAR. */
|
46
|
-
template_string =
|
47
|
-
GPR_ASSERT(template_string);
|
45
|
+
grpc_core::TcharString template_string = grpc_core::CharToTchar(prefix);
|
48
46
|
|
49
47
|
/* Get the path to the best temporary folder available. */
|
50
48
|
status = GetTempPath(MAX_PATH, tmp_path);
|
51
49
|
if (status == 0 || status > MAX_PATH) goto end;
|
52
50
|
|
53
51
|
/* Generate a unique filename with our template + temporary path. */
|
54
|
-
success = GetTempFileName(tmp_path, template_string, 0, tmp_filename);
|
52
|
+
success = GetTempFileName(tmp_path, template_string.c_str(), 0, tmp_filename);
|
55
53
|
if (!success) goto end;
|
56
54
|
|
57
55
|
/* Open a file there. */
|
@@ -59,10 +57,10 @@ FILE* gpr_tmpfile(const char* prefix, char** tmp_filename_out) {
|
|
59
57
|
|
60
58
|
end:
|
61
59
|
if (result && tmp_filename_out) {
|
62
|
-
*tmp_filename_out =
|
60
|
+
*tmp_filename_out =
|
61
|
+
gpr_strdup(grpc_core::TcharToChar(tmp_filename).c_str());
|
63
62
|
}
|
64
63
|
|
65
|
-
gpr_free(template_string);
|
66
64
|
return result;
|
67
65
|
}
|
68
66
|
|
data/src/core/lib/gpr/useful.h
CHANGED
@@ -153,6 +153,17 @@ inline uint32_t MixHash32(uint32_t a, uint32_t b) {
|
|
153
153
|
return RotateLeft(a, 2u) ^ b;
|
154
154
|
}
|
155
155
|
|
156
|
+
inline uint32_t RoundUpToPowerOf2(uint32_t v) {
|
157
|
+
v--;
|
158
|
+
v |= v >> 1;
|
159
|
+
v |= v >> 2;
|
160
|
+
v |= v >> 4;
|
161
|
+
v |= v >> 8;
|
162
|
+
v |= v >> 16;
|
163
|
+
v++;
|
164
|
+
return v;
|
165
|
+
}
|
166
|
+
|
156
167
|
} // namespace grpc_core
|
157
168
|
|
158
169
|
#define GPR_ARRAY_SIZE(array) (sizeof(array) / sizeof(*(array)))
|
@@ -16,25 +16,38 @@
|
|
16
16
|
*
|
17
17
|
*/
|
18
18
|
|
19
|
-
#ifndef
|
20
|
-
#define
|
19
|
+
#ifndef GRPC_CORE_LIB_GPRPP_ENV_H
|
20
|
+
#define GRPC_CORE_LIB_GPRPP_ENV_H
|
21
21
|
|
22
22
|
#include <grpc/support/port_platform.h>
|
23
23
|
|
24
|
-
#include <
|
24
|
+
#include <string>
|
25
25
|
|
26
|
-
|
26
|
+
#include "absl/types/optional.h"
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
char* gpr_getenv(const char* name);
|
28
|
+
namespace grpc_core {
|
29
|
+
|
30
|
+
// Gets the environment variable value with the specified name. */
|
31
|
+
absl::optional<std::string> GetEnv(const char* name);
|
33
32
|
|
34
33
|
/* Sets the environment with the specified name to the specified value. */
|
35
|
-
void
|
34
|
+
void SetEnv(const char* name, const char* value);
|
35
|
+
inline void SetEnv(const char* name, const std::string& value) {
|
36
|
+
SetEnv(name, value.c_str());
|
37
|
+
}
|
36
38
|
|
37
39
|
/* Deletes the variable name from the environment. */
|
38
|
-
void
|
40
|
+
void UnsetEnv(const char* name);
|
41
|
+
|
42
|
+
template <typename T>
|
43
|
+
void SetOrUnsetEnv(const char* name, const absl::optional<T>& value) {
|
44
|
+
if (value.has_value()) {
|
45
|
+
SetEnv(name, value.value());
|
46
|
+
} else {
|
47
|
+
UnsetEnv(name);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
} // namespace grpc_core
|
39
52
|
|
40
|
-
#endif /*
|
53
|
+
#endif /* GRPC_CORE_LIB_GPRPP_ENV_H */
|
@@ -23,21 +23,24 @@
|
|
23
23
|
|
24
24
|
#include <grpc/support/port_platform.h>
|
25
25
|
|
26
|
+
#include <string>
|
27
|
+
|
28
|
+
#include "absl/types/optional.h"
|
29
|
+
|
26
30
|
#ifdef GPR_LINUX_ENV
|
27
31
|
|
32
|
+
#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE)
|
28
33
|
#include <dlfcn.h>
|
34
|
+
#endif
|
35
|
+
|
29
36
|
#include <features.h>
|
30
37
|
#include <stdlib.h>
|
31
|
-
#include <string.h>
|
32
38
|
|
33
|
-
#include
|
34
|
-
#include <grpc/support/string_util.h>
|
39
|
+
#include "src/core/lib/gprpp/env.h"
|
35
40
|
|
36
|
-
|
37
|
-
#include "src/core/lib/gpr/string.h"
|
38
|
-
#include "src/core/lib/gpr/useful.h"
|
41
|
+
namespace grpc_core {
|
39
42
|
|
40
|
-
|
43
|
+
absl::optional<std::string> GetEnv(const char* name) {
|
41
44
|
char* result = nullptr;
|
42
45
|
#if defined(GPR_BACKWARDS_COMPATIBILITY_MODE)
|
43
46
|
typedef char* (*getenv_type)(const char*);
|
@@ -45,9 +48,8 @@ char* gpr_getenv(const char* name) {
|
|
45
48
|
/* Check to see which getenv variant is supported (go from most
|
46
49
|
* to least secure) */
|
47
50
|
if (getenv_func == nullptr) {
|
48
|
-
|
49
|
-
|
50
|
-
getenv_func = (getenv_type)dlsym(RTLD_DEFAULT, names[i]);
|
51
|
+
for (auto name : {"secure_getenv", "__secure_getenv", "getenv"}) {
|
52
|
+
getenv_func = reinterpret_cast<getenv_type>(dlsym(RTLD_DEFAULT, name));
|
51
53
|
if (getenv_func != nullptr) {
|
52
54
|
break;
|
53
55
|
}
|
@@ -59,17 +61,20 @@ char* gpr_getenv(const char* name) {
|
|
59
61
|
#else
|
60
62
|
result = getenv(name);
|
61
63
|
#endif
|
62
|
-
|
64
|
+
if (result == nullptr) return absl::nullopt;
|
65
|
+
return result;
|
63
66
|
}
|
64
67
|
|
65
|
-
void
|
68
|
+
void SetEnv(const char* name, const char* value) {
|
66
69
|
int res = setenv(name, value, 1);
|
67
|
-
|
70
|
+
if (res != 0) abort();
|
68
71
|
}
|
69
72
|
|
70
|
-
void
|
73
|
+
void UnsetEnv(const char* name) {
|
71
74
|
int res = unsetenv(name);
|
72
|
-
|
75
|
+
if (res != 0) abort();
|
73
76
|
}
|
74
77
|
|
78
|
+
} // namespace grpc_core
|
79
|
+
|
75
80
|
#endif /* GPR_LINUX_ENV */
|
@@ -22,25 +22,26 @@
|
|
22
22
|
|
23
23
|
#include <stdlib.h>
|
24
24
|
|
25
|
-
#include
|
26
|
-
#include <grpc/support/string_util.h>
|
25
|
+
#include "src/core/lib/gprpp/env.h"
|
27
26
|
|
28
|
-
|
29
|
-
#include "src/core/lib/gpr/string.h"
|
27
|
+
namespace grpc_core {
|
30
28
|
|
31
|
-
|
29
|
+
absl::optional<std::string> GetEnv(const char* name) {
|
32
30
|
char* result = getenv(name);
|
33
|
-
|
31
|
+
if (result == nullptr) return absl::nullopt;
|
32
|
+
return result;
|
34
33
|
}
|
35
34
|
|
36
|
-
void
|
35
|
+
void SetEnv(const char* name, const char* value) {
|
37
36
|
int res = setenv(name, value, 1);
|
38
|
-
|
37
|
+
if (res != 0) abort();
|
39
38
|
}
|
40
39
|
|
41
|
-
void
|
40
|
+
void UnsetEnv(const char* name) {
|
42
41
|
int res = unsetenv(name);
|
43
|
-
|
42
|
+
if (res != 0) abort();
|
44
43
|
}
|
45
44
|
|
45
|
+
} // namespace grpc_core
|
46
|
+
|
46
47
|
#endif /* GPR_POSIX_ENV */
|
@@ -0,0 +1,56 @@
|
|
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
|
+
#include <grpc/support/port_platform.h>
|
20
|
+
|
21
|
+
#ifdef GPR_WINDOWS_ENV
|
22
|
+
|
23
|
+
#include <windows.h>
|
24
|
+
|
25
|
+
#include <memory>
|
26
|
+
|
27
|
+
#include "src/core/lib/gprpp/env.h"
|
28
|
+
#include "src/core/lib/gprpp/tchar.h"
|
29
|
+
|
30
|
+
namespace grpc_core {
|
31
|
+
|
32
|
+
absl::optional<std::string> GetEnv(const char* name) {
|
33
|
+
auto tname = CharToTchar(name);
|
34
|
+
DWORD ret = GetEnvironmentVariable(tname.c_str(), NULL, 0);
|
35
|
+
if (ret == 0) return absl::nullopt;
|
36
|
+
std::unique_ptr<TCHAR[]> tresult(new TCHAR[ret]);
|
37
|
+
ret =
|
38
|
+
GetEnvironmentVariable(tname.c_str(), tresult.get(), ret * sizeof(TCHAR));
|
39
|
+
if (ret == 0) return absl::nullopt;
|
40
|
+
return TcharToChar(tresult.get());
|
41
|
+
}
|
42
|
+
|
43
|
+
void SetEnv(const char* name, const char* value) {
|
44
|
+
BOOL res = SetEnvironmentVariable(CharToTchar(name).c_str(),
|
45
|
+
CharToTchar(value).c_str());
|
46
|
+
if (!res) abort();
|
47
|
+
}
|
48
|
+
|
49
|
+
void UnsetEnv(const char* name) {
|
50
|
+
BOOL res = SetEnvironmentVariable(CharToTchar(name).c_str(), NULL);
|
51
|
+
if (!res) abort();
|
52
|
+
}
|
53
|
+
|
54
|
+
} // namespace grpc_core
|
55
|
+
|
56
|
+
#endif /* GPR_WINDOWS_ENV */
|
data/src/core/lib/gprpp/fork.cc
CHANGED
@@ -26,6 +26,7 @@
|
|
26
26
|
#include <grpc/support/time.h>
|
27
27
|
|
28
28
|
#include "src/core/lib/gprpp/global_config_env.h"
|
29
|
+
#include "src/core/lib/gprpp/no_destruct.h"
|
29
30
|
|
30
31
|
/*
|
31
32
|
* NOTE: FORKING IS NOT GENERALLY SUPPORTED, THIS IS ONLY INTENDED TO WORK
|
@@ -43,7 +44,7 @@ GPR_GLOBAL_CONFIG_DEFINE_BOOL(grpc_enable_fork_support,
|
|
43
44
|
"Enable fork support");
|
44
45
|
|
45
46
|
namespace grpc_core {
|
46
|
-
namespace
|
47
|
+
namespace {
|
47
48
|
// The exec_ctx_count has 2 modes, blocked and unblocked.
|
48
49
|
// When unblocked, the count is 2-indexed; exec_ctx_count=2 indicates
|
49
50
|
// 0 active ExecCtxs, exex_ctx_count=3 indicates 1 active ExecCtxs...
|
@@ -161,24 +162,13 @@ class ThreadState {
|
|
161
162
|
int count_;
|
162
163
|
};
|
163
164
|
|
164
|
-
} // namespace
|
165
|
+
} // namespace
|
165
166
|
|
166
167
|
void Fork::GlobalInit() {
|
167
168
|
if (!override_enabled_) {
|
168
169
|
support_enabled_.store(GPR_GLOBAL_CONFIG_GET(grpc_enable_fork_support),
|
169
170
|
std::memory_order_relaxed);
|
170
171
|
}
|
171
|
-
if (support_enabled_.load(std::memory_order_relaxed)) {
|
172
|
-
exec_ctx_state_ = new internal::ExecCtxState();
|
173
|
-
thread_state_ = new internal::ThreadState();
|
174
|
-
}
|
175
|
-
}
|
176
|
-
|
177
|
-
void Fork::GlobalShutdown() {
|
178
|
-
if (support_enabled_.load(std::memory_order_relaxed)) {
|
179
|
-
delete exec_ctx_state_;
|
180
|
-
delete thread_state_;
|
181
|
-
}
|
182
172
|
}
|
183
173
|
|
184
174
|
bool Fork::Enabled() {
|
@@ -191,9 +181,13 @@ void Fork::Enable(bool enable) {
|
|
191
181
|
support_enabled_.store(enable, std::memory_order_relaxed);
|
192
182
|
}
|
193
183
|
|
194
|
-
void Fork::DoIncExecCtxCount() {
|
184
|
+
void Fork::DoIncExecCtxCount() {
|
185
|
+
NoDestructSingleton<ExecCtxState>::Get()->IncExecCtxCount();
|
186
|
+
}
|
195
187
|
|
196
|
-
void Fork::DoDecExecCtxCount() {
|
188
|
+
void Fork::DoDecExecCtxCount() {
|
189
|
+
NoDestructSingleton<ExecCtxState>::Get()->DecExecCtxCount();
|
190
|
+
}
|
197
191
|
|
198
192
|
void Fork::SetResetChildPollingEngineFunc(
|
199
193
|
Fork::child_postfork_func reset_child_polling_engine) {
|
@@ -205,36 +199,34 @@ Fork::child_postfork_func Fork::GetResetChildPollingEngineFunc() {
|
|
205
199
|
|
206
200
|
bool Fork::BlockExecCtx() {
|
207
201
|
if (support_enabled_.load(std::memory_order_relaxed)) {
|
208
|
-
return
|
202
|
+
return NoDestructSingleton<ExecCtxState>::Get()->BlockExecCtx();
|
209
203
|
}
|
210
204
|
return false;
|
211
205
|
}
|
212
206
|
|
213
207
|
void Fork::AllowExecCtx() {
|
214
208
|
if (support_enabled_.load(std::memory_order_relaxed)) {
|
215
|
-
|
209
|
+
NoDestructSingleton<ExecCtxState>::Get()->AllowExecCtx();
|
216
210
|
}
|
217
211
|
}
|
218
212
|
|
219
213
|
void Fork::IncThreadCount() {
|
220
214
|
if (support_enabled_.load(std::memory_order_relaxed)) {
|
221
|
-
|
215
|
+
NoDestructSingleton<ThreadState>::Get()->IncThreadCount();
|
222
216
|
}
|
223
217
|
}
|
224
218
|
|
225
219
|
void Fork::DecThreadCount() {
|
226
220
|
if (support_enabled_.load(std::memory_order_relaxed)) {
|
227
|
-
|
221
|
+
NoDestructSingleton<ThreadState>::Get()->DecThreadCount();
|
228
222
|
}
|
229
223
|
}
|
230
224
|
void Fork::AwaitThreads() {
|
231
225
|
if (support_enabled_.load(std::memory_order_relaxed)) {
|
232
|
-
|
226
|
+
NoDestructSingleton<ThreadState>::Get()->AwaitThreads();
|
233
227
|
}
|
234
228
|
}
|
235
229
|
|
236
|
-
internal::ExecCtxState* Fork::exec_ctx_state_ = nullptr;
|
237
|
-
internal::ThreadState* Fork::thread_state_ = nullptr;
|
238
230
|
std::atomic<bool> Fork::support_enabled_(false);
|
239
231
|
bool Fork::override_enabled_ = false;
|
240
232
|
Fork::child_postfork_func Fork::reset_child_polling_engine_ = nullptr;
|
data/src/core/lib/gprpp/fork.h
CHANGED
@@ -30,17 +30,11 @@
|
|
30
30
|
|
31
31
|
namespace grpc_core {
|
32
32
|
|
33
|
-
namespace internal {
|
34
|
-
class ExecCtxState;
|
35
|
-
class ThreadState;
|
36
|
-
} // namespace internal
|
37
|
-
|
38
33
|
class Fork {
|
39
34
|
public:
|
40
35
|
typedef void (*child_postfork_func)(void);
|
41
36
|
|
42
37
|
static void GlobalInit();
|
43
|
-
static void GlobalShutdown();
|
44
38
|
|
45
39
|
// Returns true if fork suppport is enabled, false otherwise
|
46
40
|
static bool Enabled();
|
@@ -91,8 +85,6 @@ class Fork {
|
|
91
85
|
static void DoIncExecCtxCount();
|
92
86
|
static void DoDecExecCtxCount();
|
93
87
|
|
94
|
-
static internal::ExecCtxState* exec_ctx_state_;
|
95
|
-
static internal::ThreadState* thread_state_;
|
96
88
|
static std::atomic<bool> support_enabled_;
|
97
89
|
static bool override_enabled_;
|
98
90
|
static child_postfork_func reset_child_polling_engine_;
|
@@ -28,12 +28,13 @@
|
|
28
28
|
#include <type_traits>
|
29
29
|
|
30
30
|
#include "absl/strings/str_format.h"
|
31
|
+
#include "absl/types/optional.h"
|
31
32
|
|
32
33
|
#include <grpc/support/log.h>
|
33
34
|
#include <grpc/support/string_util.h>
|
34
35
|
|
35
|
-
#include "src/core/lib/gpr/env.h"
|
36
36
|
#include "src/core/lib/gpr/string.h"
|
37
|
+
#include "src/core/lib/gprpp/env.h"
|
37
38
|
|
38
39
|
namespace grpc_core {
|
39
40
|
|
@@ -60,14 +61,14 @@ void SetGlobalConfigEnvErrorFunction(GlobalConfigEnvErrorFunctionType func) {
|
|
60
61
|
}
|
61
62
|
|
62
63
|
UniquePtr<char> GlobalConfigEnv::GetValue() {
|
63
|
-
|
64
|
+
auto env = GetEnv(GetName());
|
65
|
+
return UniquePtr<char>(env.has_value() ? gpr_strdup(env.value().c_str())
|
66
|
+
: nullptr);
|
64
67
|
}
|
65
68
|
|
66
|
-
void GlobalConfigEnv::SetValue(const char* value) {
|
67
|
-
gpr_setenv(GetName(), value);
|
68
|
-
}
|
69
|
+
void GlobalConfigEnv::SetValue(const char* value) { SetEnv(GetName(), value); }
|
69
70
|
|
70
|
-
void GlobalConfigEnv::Unset() {
|
71
|
+
void GlobalConfigEnv::Unset() { UnsetEnv(GetName()); }
|
71
72
|
|
72
73
|
char* GlobalConfigEnv::GetName() {
|
73
74
|
// This makes sure that name_ is in a canonical form having uppercase
|
@@ -0,0 +1,67 @@
|
|
1
|
+
// Copyright 2022 The gRPC Authors
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
#ifndef GRPC_CORE_LIB_GPRPP_NOTIFICATION_H
|
16
|
+
#define GRPC_CORE_LIB_GPRPP_NOTIFICATION_H
|
17
|
+
|
18
|
+
#include <grpc/support/port_platform.h>
|
19
|
+
|
20
|
+
#include "absl/time/clock.h"
|
21
|
+
#include "absl/time/time.h"
|
22
|
+
|
23
|
+
#include "src/core/lib/gprpp/sync.h"
|
24
|
+
|
25
|
+
namespace grpc_core {
|
26
|
+
|
27
|
+
// Polyfill for absl::Notification until we can use that type.
|
28
|
+
class Notification {
|
29
|
+
public:
|
30
|
+
void Notify() {
|
31
|
+
MutexLock lock(&mu_);
|
32
|
+
notified_ = true;
|
33
|
+
cv_.SignalAll();
|
34
|
+
}
|
35
|
+
|
36
|
+
void WaitForNotification() {
|
37
|
+
MutexLock lock(&mu_);
|
38
|
+
while (!notified_) {
|
39
|
+
cv_.Wait(&mu_);
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
bool WaitForNotificationWithTimeout(absl::Duration timeout) {
|
44
|
+
auto now = absl::Now();
|
45
|
+
auto deadline = now + timeout;
|
46
|
+
MutexLock lock(&mu_);
|
47
|
+
while (!notified_ && now < deadline) {
|
48
|
+
cv_.WaitWithTimeout(&mu_, deadline - now);
|
49
|
+
now = absl::Now();
|
50
|
+
}
|
51
|
+
return notified_;
|
52
|
+
}
|
53
|
+
|
54
|
+
bool HasBeenNotified() {
|
55
|
+
MutexLock lock(&mu_);
|
56
|
+
return notified_;
|
57
|
+
}
|
58
|
+
|
59
|
+
private:
|
60
|
+
Mutex mu_;
|
61
|
+
CondVar cv_;
|
62
|
+
bool notified_ = false;
|
63
|
+
};
|
64
|
+
|
65
|
+
} // namespace grpc_core
|
66
|
+
|
67
|
+
#endif // GRPC_CORE_LIB_GPRPP_NOTIFICATION_H
|
@@ -0,0 +1,40 @@
|
|
1
|
+
// Copyright 2022 gRPC authors.
|
2
|
+
//
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
// you may not use this file except in compliance with the License.
|
5
|
+
// You may obtain a copy of the License at
|
6
|
+
//
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
//
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
// See the License for the specific language governing permissions and
|
13
|
+
// limitations under the License.
|
14
|
+
|
15
|
+
#ifndef GRPC_CORE_LIB_GPRPP_PACKED_TABLE_H
|
16
|
+
#define GRPC_CORE_LIB_GPRPP_PACKED_TABLE_H
|
17
|
+
|
18
|
+
#include <grpc/support/port_platform.h>
|
19
|
+
|
20
|
+
#include "src/core/lib/gprpp/sorted_pack.h"
|
21
|
+
#include "src/core/lib/gprpp/table.h"
|
22
|
+
|
23
|
+
namespace grpc_core {
|
24
|
+
|
25
|
+
namespace packed_table_detail {
|
26
|
+
template <typename A, typename B>
|
27
|
+
struct Cmp {
|
28
|
+
static constexpr bool kValue = alignof(A) > alignof(B) ||
|
29
|
+
(alignof(A) == alignof(B) &&
|
30
|
+
sizeof(A) > sizeof(B));
|
31
|
+
};
|
32
|
+
}; // namespace packed_table_detail
|
33
|
+
|
34
|
+
template <typename... T>
|
35
|
+
using PackedTable =
|
36
|
+
typename WithSortedPack<Table, packed_table_detail::Cmp, T...>::Type;
|
37
|
+
|
38
|
+
} // namespace grpc_core
|
39
|
+
|
40
|
+
#endif // GRPC_CORE_LIB_GPRPP_PACKED_TABLE_H
|