grpc 1.26.0 → 1.27.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 +1654 -1519
- data/etc/roots.pem +44 -0
- data/include/grpc/grpc_security.h +37 -15
- data/include/grpc/grpc_security_constants.h +27 -0
- data/include/grpc/impl/codegen/grpc_types.h +14 -0
- data/include/grpc/impl/codegen/port_platform.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel.cc +0 -20
- data/src/core/ext/filters/client_channel/http_proxy.cc +4 -4
- data/src/core/ext/filters/client_channel/lb_policy.cc +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +191 -201
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.cc +89 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_balancer_addresses.h +40 -0
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel_secure.cc +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +88 -121
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.h +28 -57
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +0 -7
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +8 -9
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +53 -34
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +18 -5
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +24 -19
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -2
- data/src/core/ext/filters/client_channel/server_address.cc +6 -9
- data/src/core/ext/filters/client_channel/server_address.h +3 -10
- data/src/core/ext/filters/client_channel/xds/xds_api.cc +394 -150
- data/src/core/ext/filters/client_channel/xds/xds_api.h +75 -35
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +59 -22
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +13 -9
- data/src/core/ext/filters/client_channel/xds/xds_channel_secure.cc +8 -6
- data/src/core/ext/filters/client_channel/xds/xds_client.cc +456 -175
- data/src/core/ext/filters/client_channel/xds/xds_client.h +33 -21
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +5 -8
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +18 -24
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +2 -2
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.c +13 -5
- data/src/core/ext/upb-generated/src/proto/grpc/lb/v1/load_balancer.upb.h +34 -0
- data/src/core/lib/channel/channelz.h +11 -1
- data/src/core/lib/gpr/time_precise.cc +1 -1
- data/src/core/lib/gprpp/optional.h +26 -0
- data/src/core/lib/gprpp/string_view.h +14 -10
- data/src/core/lib/iomgr/executor.cc +1 -1
- data/src/core/lib/iomgr/fork_posix.cc +4 -0
- data/src/core/lib/iomgr/poller/eventmanager_libuv.cc +87 -0
- data/src/core/lib/iomgr/poller/eventmanager_libuv.h +88 -0
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +14 -0
- data/src/core/lib/iomgr/socket_utils_posix.h +12 -0
- data/src/core/lib/iomgr/tcp_custom.h +3 -0
- data/src/core/lib/iomgr/tcp_posix.cc +607 -56
- data/src/core/lib/iomgr/tcp_server_custom.cc +15 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +8 -0
- data/src/core/lib/json/json.h +11 -1
- data/src/core/lib/json/json_reader.cc +206 -28
- data/src/core/lib/json/json_writer.cc +111 -24
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +7 -0
- data/src/core/lib/security/credentials/composite/composite_credentials.h +5 -1
- data/src/core/lib/security/credentials/credentials.h +10 -1
- data/src/core/lib/security/credentials/fake/fake_credentials.h +2 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -1
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -4
- data/src/core/lib/security/credentials/plugin/plugin_credentials.h +2 -1
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +20 -0
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.h +8 -0
- data/src/core/lib/security/credentials/tls/{spiffe_credentials.cc → tls_credentials.cc} +23 -24
- data/src/core/lib/security/credentials/tls/{spiffe_credentials.h → tls_credentials.h} +9 -9
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +13 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +22 -2
- data/src/core/lib/security/security_connector/load_system_roots_fallback.cc +2 -2
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -2
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +30 -3
- data/src/core/lib/security/security_connector/ssl_utils.cc +45 -3
- data/src/core/lib/security/security_connector/ssl_utils.h +12 -0
- data/src/core/lib/security/security_connector/tls/{spiffe_security_connector.cc → tls_security_connector.cc} +82 -69
- data/src/core/lib/security/security_connector/tls/{spiffe_security_connector.h → tls_security_connector.h} +17 -18
- data/src/core/lib/security/transport/client_auth_filter.cc +33 -0
- data/src/core/lib/surface/completion_queue.cc +22 -1
- data/src/core/lib/surface/version.cc +1 -1
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +11 -1
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +1 -1
- data/src/core/tsi/alts/zero_copy_frame_protector/alts_zero_copy_grpc_protector.cc +3 -3
- data/src/core/tsi/fake_transport_security.cc +7 -3
- data/src/core/tsi/fake_transport_security.h +2 -0
- data/src/core/tsi/ssl_transport_security.cc +144 -8
- data/src/core/tsi/ssl_transport_security.h +15 -1
- data/src/core/tsi/transport_security.cc +13 -0
- data/src/core/tsi/transport_security_grpc.cc +2 -2
- data/src/core/tsi/transport_security_grpc.h +2 -2
- data/src/core/tsi/transport_security_interface.h +12 -0
- data/src/ruby/bin/math_pb.rb +5 -5
- data/src/ruby/ext/grpc/rb_call_credentials.c +4 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +2 -0
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +4 -1
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/pb/grpc/health/v1/health_pb.rb +3 -3
- data/src/ruby/pb/src/proto/grpc/testing/empty_pb.rb +1 -1
- data/src/ruby/pb/src/proto/grpc/testing/messages_pb.rb +23 -13
- data/third_party/abseil-cpp/absl/algorithm/algorithm.h +159 -0
- data/third_party/abseil-cpp/absl/base/attributes.h +609 -0
- data/third_party/abseil-cpp/absl/base/call_once.h +226 -0
- data/third_party/abseil-cpp/absl/base/casts.h +184 -0
- data/third_party/abseil-cpp/absl/base/config.h +622 -0
- data/third_party/abseil-cpp/absl/base/const_init.h +76 -0
- data/third_party/abseil-cpp/absl/base/dynamic_annotations.cc +129 -0
- data/third_party/abseil-cpp/absl/base/dynamic_annotations.h +389 -0
- data/third_party/abseil-cpp/absl/base/internal/atomic_hook.h +179 -0
- data/third_party/abseil-cpp/absl/base/internal/bits.h +218 -0
- data/third_party/abseil-cpp/absl/base/internal/cycleclock.cc +107 -0
- data/third_party/abseil-cpp/absl/base/internal/cycleclock.h +94 -0
- data/third_party/abseil-cpp/absl/base/internal/endian.h +266 -0
- data/third_party/abseil-cpp/absl/base/internal/hide_ptr.h +51 -0
- data/third_party/abseil-cpp/absl/base/internal/identity.h +37 -0
- data/third_party/abseil-cpp/absl/base/internal/inline_variable.h +107 -0
- data/third_party/abseil-cpp/absl/base/internal/invoke.h +187 -0
- data/third_party/abseil-cpp/absl/base/internal/low_level_scheduling.h +107 -0
- data/third_party/abseil-cpp/absl/base/internal/per_thread_tls.h +52 -0
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.cc +237 -0
- data/third_party/abseil-cpp/absl/base/internal/raw_logging.h +179 -0
- data/third_party/abseil-cpp/absl/base/internal/scheduling_mode.h +58 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock.cc +233 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock.h +243 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_akaros.inc +35 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_linux.inc +67 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_posix.inc +46 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.cc +81 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_wait.h +93 -0
- data/third_party/abseil-cpp/absl/base/internal/spinlock_win32.inc +37 -0
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.cc +414 -0
- data/third_party/abseil-cpp/absl/base/internal/sysinfo.h +66 -0
- data/third_party/abseil-cpp/absl/base/internal/thread_annotations.h +271 -0
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.cc +140 -0
- data/third_party/abseil-cpp/absl/base/internal/thread_identity.h +250 -0
- data/third_party/abseil-cpp/absl/base/internal/throw_delegate.cc +108 -0
- data/third_party/abseil-cpp/absl/base/internal/throw_delegate.h +75 -0
- data/third_party/abseil-cpp/absl/base/internal/tsan_mutex_interface.h +66 -0
- data/third_party/abseil-cpp/absl/base/internal/unaligned_access.h +158 -0
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc +103 -0
- data/third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h +124 -0
- data/third_party/abseil-cpp/absl/base/log_severity.cc +27 -0
- data/third_party/abseil-cpp/absl/base/log_severity.h +121 -0
- data/third_party/abseil-cpp/absl/base/macros.h +220 -0
- data/third_party/abseil-cpp/absl/base/optimization.h +181 -0
- data/third_party/abseil-cpp/absl/base/options.h +214 -0
- data/third_party/abseil-cpp/absl/base/policy_checks.h +111 -0
- data/third_party/abseil-cpp/absl/base/port.h +26 -0
- data/third_party/abseil-cpp/absl/base/thread_annotations.h +280 -0
- data/third_party/abseil-cpp/absl/container/inlined_vector.h +848 -0
- data/third_party/abseil-cpp/absl/container/internal/compressed_tuple.h +265 -0
- data/third_party/abseil-cpp/absl/container/internal/inlined_vector.h +892 -0
- data/third_party/abseil-cpp/absl/memory/memory.h +695 -0
- data/third_party/abseil-cpp/absl/meta/type_traits.h +759 -0
- data/third_party/abseil-cpp/absl/numeric/int128.cc +404 -0
- data/third_party/abseil-cpp/absl/numeric/int128.h +1091 -0
- data/third_party/abseil-cpp/absl/numeric/int128_have_intrinsic.inc +302 -0
- data/third_party/abseil-cpp/absl/numeric/int128_no_intrinsic.inc +308 -0
- data/third_party/abseil-cpp/absl/strings/ascii.cc +200 -0
- data/third_party/abseil-cpp/absl/strings/ascii.h +241 -0
- data/third_party/abseil-cpp/absl/strings/charconv.cc +985 -0
- data/third_party/abseil-cpp/absl/strings/charconv.h +119 -0
- data/third_party/abseil-cpp/absl/strings/escaping.cc +949 -0
- data/third_party/abseil-cpp/absl/strings/escaping.h +164 -0
- data/third_party/abseil-cpp/absl/strings/internal/char_map.h +156 -0
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.cc +359 -0
- data/third_party/abseil-cpp/absl/strings/internal/charconv_bigint.h +421 -0
- data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.cc +504 -0
- data/third_party/abseil-cpp/absl/strings/internal/charconv_parse.h +99 -0
- data/third_party/abseil-cpp/absl/strings/internal/escaping.cc +180 -0
- data/third_party/abseil-cpp/absl/strings/internal/escaping.h +58 -0
- data/third_party/abseil-cpp/absl/strings/internal/memutil.cc +112 -0
- data/third_party/abseil-cpp/absl/strings/internal/memutil.h +148 -0
- data/third_party/abseil-cpp/absl/strings/internal/ostringstream.cc +36 -0
- data/third_party/abseil-cpp/absl/strings/internal/ostringstream.h +89 -0
- data/third_party/abseil-cpp/absl/strings/internal/resize_uninitialized.h +73 -0
- data/third_party/abseil-cpp/absl/strings/internal/stl_type_traits.h +248 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_join_internal.h +314 -0
- data/third_party/abseil-cpp/absl/strings/internal/str_split_internal.h +455 -0
- data/third_party/abseil-cpp/absl/strings/internal/utf8.cc +53 -0
- data/third_party/abseil-cpp/absl/strings/internal/utf8.h +50 -0
- data/third_party/abseil-cpp/absl/strings/match.cc +40 -0
- data/third_party/abseil-cpp/absl/strings/match.h +90 -0
- data/third_party/abseil-cpp/absl/strings/numbers.cc +916 -0
- data/third_party/abseil-cpp/absl/strings/numbers.h +263 -0
- data/third_party/abseil-cpp/absl/strings/str_cat.cc +246 -0
- data/third_party/abseil-cpp/absl/strings/str_cat.h +408 -0
- data/third_party/abseil-cpp/absl/strings/str_join.h +293 -0
- data/third_party/abseil-cpp/absl/strings/str_replace.cc +82 -0
- data/third_party/abseil-cpp/absl/strings/str_replace.h +219 -0
- data/third_party/abseil-cpp/absl/strings/str_split.cc +139 -0
- data/third_party/abseil-cpp/absl/strings/str_split.h +513 -0
- data/third_party/abseil-cpp/absl/strings/string_view.cc +235 -0
- data/third_party/abseil-cpp/absl/strings/string_view.h +615 -0
- data/third_party/abseil-cpp/absl/strings/strip.h +91 -0
- data/third_party/abseil-cpp/absl/strings/substitute.cc +171 -0
- data/third_party/abseil-cpp/absl/strings/substitute.h +693 -0
- data/third_party/abseil-cpp/absl/types/bad_optional_access.cc +48 -0
- data/third_party/abseil-cpp/absl/types/bad_optional_access.h +78 -0
- data/third_party/abseil-cpp/absl/types/internal/optional.h +396 -0
- data/third_party/abseil-cpp/absl/types/internal/span.h +128 -0
- data/third_party/abseil-cpp/absl/types/optional.h +776 -0
- data/third_party/abseil-cpp/absl/types/span.h +713 -0
- data/third_party/abseil-cpp/absl/utility/utility.h +350 -0
- data/third_party/upb/upb/decode.c +4 -0
- data/third_party/upb/upb/port.c +0 -1
- data/third_party/upb/upb/port_def.inc +1 -3
- data/third_party/upb/upb/table.c +2 -1
- metadata +147 -43
- data/src/core/lib/json/json_common.h +0 -34
- data/src/core/lib/json/json_reader.h +0 -146
- data/src/core/lib/json/json_string.cc +0 -367
- data/src/core/lib/json/json_writer.h +0 -84
@@ -0,0 +1,107 @@
|
|
1
|
+
// Copyright 2017 The Abseil 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
|
+
// https://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 ABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_
|
16
|
+
#define ABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_
|
17
|
+
|
18
|
+
#include <type_traits>
|
19
|
+
|
20
|
+
#include "absl/base/internal/identity.h"
|
21
|
+
|
22
|
+
// File:
|
23
|
+
// This file define a macro that allows the creation of or emulation of C++17
|
24
|
+
// inline variables based on whether or not the feature is supported.
|
25
|
+
|
26
|
+
////////////////////////////////////////////////////////////////////////////////
|
27
|
+
// Macro: ABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init)
|
28
|
+
//
|
29
|
+
// Description:
|
30
|
+
// Expands to the equivalent of an inline constexpr instance of the specified
|
31
|
+
// `type` and `name`, initialized to the value `init`. If the compiler being
|
32
|
+
// used is detected as supporting actual inline variables as a language
|
33
|
+
// feature, then the macro expands to an actual inline variable definition.
|
34
|
+
//
|
35
|
+
// Requires:
|
36
|
+
// `type` is a type that is usable in an extern variable declaration.
|
37
|
+
//
|
38
|
+
// Requires: `name` is a valid identifier
|
39
|
+
//
|
40
|
+
// Requires:
|
41
|
+
// `init` is an expression that can be used in the following definition:
|
42
|
+
// constexpr type name = init;
|
43
|
+
//
|
44
|
+
// Usage:
|
45
|
+
//
|
46
|
+
// // Equivalent to: `inline constexpr size_t variant_npos = -1;`
|
47
|
+
// ABSL_INTERNAL_INLINE_CONSTEXPR(size_t, variant_npos, -1);
|
48
|
+
//
|
49
|
+
// Differences in implementation:
|
50
|
+
// For a direct, language-level inline variable, decltype(name) will be the
|
51
|
+
// type that was specified along with const qualification, whereas for
|
52
|
+
// emulated inline variables, decltype(name) may be different (in practice
|
53
|
+
// it will likely be a reference type).
|
54
|
+
////////////////////////////////////////////////////////////////////////////////
|
55
|
+
|
56
|
+
#ifdef __cpp_inline_variables
|
57
|
+
|
58
|
+
// Clang's -Wmissing-variable-declarations option erroneously warned that
|
59
|
+
// inline constexpr objects need to be pre-declared. This has now been fixed,
|
60
|
+
// but we will need to support this workaround for people building with older
|
61
|
+
// versions of clang.
|
62
|
+
//
|
63
|
+
// Bug: https://bugs.llvm.org/show_bug.cgi?id=35862
|
64
|
+
//
|
65
|
+
// Note:
|
66
|
+
// identity_t is used here so that the const and name are in the
|
67
|
+
// appropriate place for pointer types, reference types, function pointer
|
68
|
+
// types, etc..
|
69
|
+
#if defined(__clang__)
|
70
|
+
#define ABSL_INTERNAL_EXTERN_DECL(type, name) \
|
71
|
+
extern const ::absl::internal::identity_t<type> name;
|
72
|
+
#else // Otherwise, just define the macro to do nothing.
|
73
|
+
#define ABSL_INTERNAL_EXTERN_DECL(type, name)
|
74
|
+
#endif // defined(__clang__)
|
75
|
+
|
76
|
+
// See above comment at top of file for details.
|
77
|
+
#define ABSL_INTERNAL_INLINE_CONSTEXPR(type, name, init) \
|
78
|
+
ABSL_INTERNAL_EXTERN_DECL(type, name) \
|
79
|
+
inline constexpr ::absl::internal::identity_t<type> name = init
|
80
|
+
|
81
|
+
#else
|
82
|
+
|
83
|
+
// See above comment at top of file for details.
|
84
|
+
//
|
85
|
+
// Note:
|
86
|
+
// identity_t is used here so that the const and name are in the
|
87
|
+
// appropriate place for pointer types, reference types, function pointer
|
88
|
+
// types, etc..
|
89
|
+
#define ABSL_INTERNAL_INLINE_CONSTEXPR(var_type, name, init) \
|
90
|
+
template <class /*AbslInternalDummy*/ = void> \
|
91
|
+
struct AbslInternalInlineVariableHolder##name { \
|
92
|
+
static constexpr ::absl::internal::identity_t<var_type> kInstance = init; \
|
93
|
+
}; \
|
94
|
+
\
|
95
|
+
template <class AbslInternalDummy> \
|
96
|
+
constexpr ::absl::internal::identity_t<var_type> \
|
97
|
+
AbslInternalInlineVariableHolder##name<AbslInternalDummy>::kInstance; \
|
98
|
+
\
|
99
|
+
static constexpr const ::absl::internal::identity_t<var_type>& \
|
100
|
+
name = /* NOLINT */ \
|
101
|
+
AbslInternalInlineVariableHolder##name<>::kInstance; \
|
102
|
+
static_assert(sizeof(void (*)(decltype(name))) != 0, \
|
103
|
+
"Silence unused variable warnings.")
|
104
|
+
|
105
|
+
#endif // __cpp_inline_variables
|
106
|
+
|
107
|
+
#endif // ABSL_BASE_INTERNAL_INLINE_VARIABLE_EMULATION_H_
|
@@ -0,0 +1,187 @@
|
|
1
|
+
// Copyright 2017 The Abseil 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
|
+
// https://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
|
+
// absl::base_internal::Invoke(f, args...) is an implementation of
|
16
|
+
// INVOKE(f, args...) from section [func.require] of the C++ standard.
|
17
|
+
//
|
18
|
+
// [func.require]
|
19
|
+
// Define INVOKE (f, t1, t2, ..., tN) as follows:
|
20
|
+
// 1. (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T
|
21
|
+
// and t1 is an object of type T or a reference to an object of type T or a
|
22
|
+
// reference to an object of a type derived from T;
|
23
|
+
// 2. ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a
|
24
|
+
// class T and t1 is not one of the types described in the previous item;
|
25
|
+
// 3. t1.*f when N == 1 and f is a pointer to member data of a class T and t1 is
|
26
|
+
// an object of type T or a reference to an object of type T or a reference
|
27
|
+
// to an object of a type derived from T;
|
28
|
+
// 4. (*t1).*f when N == 1 and f is a pointer to member data of a class T and t1
|
29
|
+
// is not one of the types described in the previous item;
|
30
|
+
// 5. f(t1, t2, ..., tN) in all other cases.
|
31
|
+
//
|
32
|
+
// The implementation is SFINAE-friendly: substitution failure within Invoke()
|
33
|
+
// isn't an error.
|
34
|
+
|
35
|
+
#ifndef ABSL_BASE_INTERNAL_INVOKE_H_
|
36
|
+
#define ABSL_BASE_INTERNAL_INVOKE_H_
|
37
|
+
|
38
|
+
#include <algorithm>
|
39
|
+
#include <type_traits>
|
40
|
+
#include <utility>
|
41
|
+
|
42
|
+
#include "absl/meta/type_traits.h"
|
43
|
+
|
44
|
+
// The following code is internal implementation detail. See the comment at the
|
45
|
+
// top of this file for the API documentation.
|
46
|
+
|
47
|
+
namespace absl {
|
48
|
+
ABSL_NAMESPACE_BEGIN
|
49
|
+
namespace base_internal {
|
50
|
+
|
51
|
+
// The five classes below each implement one of the clauses from the definition
|
52
|
+
// of INVOKE. The inner class template Accept<F, Args...> checks whether the
|
53
|
+
// clause is applicable; static function template Invoke(f, args...) does the
|
54
|
+
// invocation.
|
55
|
+
//
|
56
|
+
// By separating the clause selection logic from invocation we make sure that
|
57
|
+
// Invoke() does exactly what the standard says.
|
58
|
+
|
59
|
+
template <typename Derived>
|
60
|
+
struct StrippedAccept {
|
61
|
+
template <typename... Args>
|
62
|
+
struct Accept : Derived::template AcceptImpl<typename std::remove_cv<
|
63
|
+
typename std::remove_reference<Args>::type>::type...> {};
|
64
|
+
};
|
65
|
+
|
66
|
+
// (t1.*f)(t2, ..., tN) when f is a pointer to a member function of a class T
|
67
|
+
// and t1 is an object of type T or a reference to an object of type T or a
|
68
|
+
// reference to an object of a type derived from T.
|
69
|
+
struct MemFunAndRef : StrippedAccept<MemFunAndRef> {
|
70
|
+
template <typename... Args>
|
71
|
+
struct AcceptImpl : std::false_type {};
|
72
|
+
|
73
|
+
template <typename MemFunType, typename C, typename Obj, typename... Args>
|
74
|
+
struct AcceptImpl<MemFunType C::*, Obj, Args...>
|
75
|
+
: std::integral_constant<bool, std::is_base_of<C, Obj>::value &&
|
76
|
+
absl::is_function<MemFunType>::value> {
|
77
|
+
};
|
78
|
+
|
79
|
+
template <typename MemFun, typename Obj, typename... Args>
|
80
|
+
static decltype((std::declval<Obj>().*
|
81
|
+
std::declval<MemFun>())(std::declval<Args>()...))
|
82
|
+
Invoke(MemFun&& mem_fun, Obj&& obj, Args&&... args) {
|
83
|
+
return (std::forward<Obj>(obj).*
|
84
|
+
std::forward<MemFun>(mem_fun))(std::forward<Args>(args)...);
|
85
|
+
}
|
86
|
+
};
|
87
|
+
|
88
|
+
// ((*t1).*f)(t2, ..., tN) when f is a pointer to a member function of a
|
89
|
+
// class T and t1 is not one of the types described in the previous item.
|
90
|
+
struct MemFunAndPtr : StrippedAccept<MemFunAndPtr> {
|
91
|
+
template <typename... Args>
|
92
|
+
struct AcceptImpl : std::false_type {};
|
93
|
+
|
94
|
+
template <typename MemFunType, typename C, typename Ptr, typename... Args>
|
95
|
+
struct AcceptImpl<MemFunType C::*, Ptr, Args...>
|
96
|
+
: std::integral_constant<bool, !std::is_base_of<C, Ptr>::value &&
|
97
|
+
absl::is_function<MemFunType>::value> {
|
98
|
+
};
|
99
|
+
|
100
|
+
template <typename MemFun, typename Ptr, typename... Args>
|
101
|
+
static decltype(((*std::declval<Ptr>()).*
|
102
|
+
std::declval<MemFun>())(std::declval<Args>()...))
|
103
|
+
Invoke(MemFun&& mem_fun, Ptr&& ptr, Args&&... args) {
|
104
|
+
return ((*std::forward<Ptr>(ptr)).*
|
105
|
+
std::forward<MemFun>(mem_fun))(std::forward<Args>(args)...);
|
106
|
+
}
|
107
|
+
};
|
108
|
+
|
109
|
+
// t1.*f when N == 1 and f is a pointer to member data of a class T and t1 is
|
110
|
+
// an object of type T or a reference to an object of type T or a reference
|
111
|
+
// to an object of a type derived from T.
|
112
|
+
struct DataMemAndRef : StrippedAccept<DataMemAndRef> {
|
113
|
+
template <typename... Args>
|
114
|
+
struct AcceptImpl : std::false_type {};
|
115
|
+
|
116
|
+
template <typename R, typename C, typename Obj>
|
117
|
+
struct AcceptImpl<R C::*, Obj>
|
118
|
+
: std::integral_constant<bool, std::is_base_of<C, Obj>::value &&
|
119
|
+
!absl::is_function<R>::value> {};
|
120
|
+
|
121
|
+
template <typename DataMem, typename Ref>
|
122
|
+
static decltype(std::declval<Ref>().*std::declval<DataMem>()) Invoke(
|
123
|
+
DataMem&& data_mem, Ref&& ref) {
|
124
|
+
return std::forward<Ref>(ref).*std::forward<DataMem>(data_mem);
|
125
|
+
}
|
126
|
+
};
|
127
|
+
|
128
|
+
// (*t1).*f when N == 1 and f is a pointer to member data of a class T and t1
|
129
|
+
// is not one of the types described in the previous item.
|
130
|
+
struct DataMemAndPtr : StrippedAccept<DataMemAndPtr> {
|
131
|
+
template <typename... Args>
|
132
|
+
struct AcceptImpl : std::false_type {};
|
133
|
+
|
134
|
+
template <typename R, typename C, typename Ptr>
|
135
|
+
struct AcceptImpl<R C::*, Ptr>
|
136
|
+
: std::integral_constant<bool, !std::is_base_of<C, Ptr>::value &&
|
137
|
+
!absl::is_function<R>::value> {};
|
138
|
+
|
139
|
+
template <typename DataMem, typename Ptr>
|
140
|
+
static decltype((*std::declval<Ptr>()).*std::declval<DataMem>()) Invoke(
|
141
|
+
DataMem&& data_mem, Ptr&& ptr) {
|
142
|
+
return (*std::forward<Ptr>(ptr)).*std::forward<DataMem>(data_mem);
|
143
|
+
}
|
144
|
+
};
|
145
|
+
|
146
|
+
// f(t1, t2, ..., tN) in all other cases.
|
147
|
+
struct Callable {
|
148
|
+
// Callable doesn't have Accept because it's the last clause that gets picked
|
149
|
+
// when none of the previous clauses are applicable.
|
150
|
+
template <typename F, typename... Args>
|
151
|
+
static decltype(std::declval<F>()(std::declval<Args>()...)) Invoke(
|
152
|
+
F&& f, Args&&... args) {
|
153
|
+
return std::forward<F>(f)(std::forward<Args>(args)...);
|
154
|
+
}
|
155
|
+
};
|
156
|
+
|
157
|
+
// Resolves to the first matching clause.
|
158
|
+
template <typename... Args>
|
159
|
+
struct Invoker {
|
160
|
+
typedef typename std::conditional<
|
161
|
+
MemFunAndRef::Accept<Args...>::value, MemFunAndRef,
|
162
|
+
typename std::conditional<
|
163
|
+
MemFunAndPtr::Accept<Args...>::value, MemFunAndPtr,
|
164
|
+
typename std::conditional<
|
165
|
+
DataMemAndRef::Accept<Args...>::value, DataMemAndRef,
|
166
|
+
typename std::conditional<DataMemAndPtr::Accept<Args...>::value,
|
167
|
+
DataMemAndPtr, Callable>::type>::type>::
|
168
|
+
type>::type type;
|
169
|
+
};
|
170
|
+
|
171
|
+
// The result type of Invoke<F, Args...>.
|
172
|
+
template <typename F, typename... Args>
|
173
|
+
using InvokeT = decltype(Invoker<F, Args...>::type::Invoke(
|
174
|
+
std::declval<F>(), std::declval<Args>()...));
|
175
|
+
|
176
|
+
// Invoke(f, args...) is an implementation of INVOKE(f, args...) from section
|
177
|
+
// [func.require] of the C++ standard.
|
178
|
+
template <typename F, typename... Args>
|
179
|
+
InvokeT<F, Args...> Invoke(F&& f, Args&&... args) {
|
180
|
+
return Invoker<F, Args...>::type::Invoke(std::forward<F>(f),
|
181
|
+
std::forward<Args>(args)...);
|
182
|
+
}
|
183
|
+
} // namespace base_internal
|
184
|
+
ABSL_NAMESPACE_END
|
185
|
+
} // namespace absl
|
186
|
+
|
187
|
+
#endif // ABSL_BASE_INTERNAL_INVOKE_H_
|
@@ -0,0 +1,107 @@
|
|
1
|
+
// Copyright 2017 The Abseil 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
|
+
// https://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
|
+
// Core interfaces and definitions used by by low-level interfaces such as
|
16
|
+
// SpinLock.
|
17
|
+
|
18
|
+
#ifndef ABSL_BASE_INTERNAL_LOW_LEVEL_SCHEDULING_H_
|
19
|
+
#define ABSL_BASE_INTERNAL_LOW_LEVEL_SCHEDULING_H_
|
20
|
+
|
21
|
+
#include "absl/base/internal/scheduling_mode.h"
|
22
|
+
#include "absl/base/macros.h"
|
23
|
+
|
24
|
+
// The following two declarations exist so SchedulingGuard may friend them with
|
25
|
+
// the appropriate language linkage. These callbacks allow libc internals, such
|
26
|
+
// as function level statics, to schedule cooperatively when locking.
|
27
|
+
extern "C" bool __google_disable_rescheduling(void);
|
28
|
+
extern "C" void __google_enable_rescheduling(bool disable_result);
|
29
|
+
|
30
|
+
namespace absl {
|
31
|
+
ABSL_NAMESPACE_BEGIN
|
32
|
+
namespace base_internal {
|
33
|
+
|
34
|
+
class SchedulingHelper; // To allow use of SchedulingGuard.
|
35
|
+
class SpinLock; // To allow use of SchedulingGuard.
|
36
|
+
|
37
|
+
// SchedulingGuard
|
38
|
+
// Provides guard semantics that may be used to disable cooperative rescheduling
|
39
|
+
// of the calling thread within specific program blocks. This is used to
|
40
|
+
// protect resources (e.g. low-level SpinLocks or Domain code) that cooperative
|
41
|
+
// scheduling depends on.
|
42
|
+
//
|
43
|
+
// Domain implementations capable of rescheduling in reaction to involuntary
|
44
|
+
// kernel thread actions (e.g blocking due to a pagefault or syscall) must
|
45
|
+
// guarantee that an annotated thread is not allowed to (cooperatively)
|
46
|
+
// reschedule until the annotated region is complete.
|
47
|
+
//
|
48
|
+
// It is an error to attempt to use a cooperatively scheduled resource (e.g.
|
49
|
+
// Mutex) within a rescheduling-disabled region.
|
50
|
+
//
|
51
|
+
// All methods are async-signal safe.
|
52
|
+
class SchedulingGuard {
|
53
|
+
public:
|
54
|
+
// Returns true iff the calling thread may be cooperatively rescheduled.
|
55
|
+
static bool ReschedulingIsAllowed();
|
56
|
+
|
57
|
+
private:
|
58
|
+
// Disable cooperative rescheduling of the calling thread. It may still
|
59
|
+
// initiate scheduling operations (e.g. wake-ups), however, it may not itself
|
60
|
+
// reschedule. Nestable. The returned result is opaque, clients should not
|
61
|
+
// attempt to interpret it.
|
62
|
+
// REQUIRES: Result must be passed to a pairing EnableScheduling().
|
63
|
+
static bool DisableRescheduling();
|
64
|
+
|
65
|
+
// Marks the end of a rescheduling disabled region, previously started by
|
66
|
+
// DisableRescheduling().
|
67
|
+
// REQUIRES: Pairs with innermost call (and result) of DisableRescheduling().
|
68
|
+
static void EnableRescheduling(bool disable_result);
|
69
|
+
|
70
|
+
// A scoped helper for {Disable, Enable}Rescheduling().
|
71
|
+
// REQUIRES: destructor must run in same thread as constructor.
|
72
|
+
struct ScopedDisable {
|
73
|
+
ScopedDisable() { disabled = SchedulingGuard::DisableRescheduling(); }
|
74
|
+
~ScopedDisable() { SchedulingGuard::EnableRescheduling(disabled); }
|
75
|
+
|
76
|
+
bool disabled;
|
77
|
+
};
|
78
|
+
|
79
|
+
// Access to SchedulingGuard is explicitly white-listed.
|
80
|
+
friend class SchedulingHelper;
|
81
|
+
friend class SpinLock;
|
82
|
+
|
83
|
+
SchedulingGuard(const SchedulingGuard&) = delete;
|
84
|
+
SchedulingGuard& operator=(const SchedulingGuard&) = delete;
|
85
|
+
};
|
86
|
+
|
87
|
+
//------------------------------------------------------------------------------
|
88
|
+
// End of public interfaces.
|
89
|
+
//------------------------------------------------------------------------------
|
90
|
+
|
91
|
+
inline bool SchedulingGuard::ReschedulingIsAllowed() {
|
92
|
+
return false;
|
93
|
+
}
|
94
|
+
|
95
|
+
inline bool SchedulingGuard::DisableRescheduling() {
|
96
|
+
return false;
|
97
|
+
}
|
98
|
+
|
99
|
+
inline void SchedulingGuard::EnableRescheduling(bool /* disable_result */) {
|
100
|
+
return;
|
101
|
+
}
|
102
|
+
|
103
|
+
} // namespace base_internal
|
104
|
+
ABSL_NAMESPACE_END
|
105
|
+
} // namespace absl
|
106
|
+
|
107
|
+
#endif // ABSL_BASE_INTERNAL_LOW_LEVEL_SCHEDULING_H_
|
@@ -0,0 +1,52 @@
|
|
1
|
+
// Copyright 2017 The Abseil 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
|
+
// https://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 ABSL_BASE_INTERNAL_PER_THREAD_TLS_H_
|
16
|
+
#define ABSL_BASE_INTERNAL_PER_THREAD_TLS_H_
|
17
|
+
|
18
|
+
// This header defines two macros:
|
19
|
+
//
|
20
|
+
// If the platform supports thread-local storage:
|
21
|
+
//
|
22
|
+
// * ABSL_PER_THREAD_TLS_KEYWORD is the C keyword needed to declare a
|
23
|
+
// thread-local variable
|
24
|
+
// * ABSL_PER_THREAD_TLS is 1
|
25
|
+
//
|
26
|
+
// Otherwise:
|
27
|
+
//
|
28
|
+
// * ABSL_PER_THREAD_TLS_KEYWORD is empty
|
29
|
+
// * ABSL_PER_THREAD_TLS is 0
|
30
|
+
//
|
31
|
+
// Microsoft C supports thread-local storage.
|
32
|
+
// GCC supports it if the appropriate version of glibc is available,
|
33
|
+
// which the programmer can indicate by defining ABSL_HAVE_TLS
|
34
|
+
|
35
|
+
#include "absl/base/port.h" // For ABSL_HAVE_TLS
|
36
|
+
|
37
|
+
#if defined(ABSL_PER_THREAD_TLS)
|
38
|
+
#error ABSL_PER_THREAD_TLS cannot be directly set
|
39
|
+
#elif defined(ABSL_PER_THREAD_TLS_KEYWORD)
|
40
|
+
#error ABSL_PER_THREAD_TLS_KEYWORD cannot be directly set
|
41
|
+
#elif defined(ABSL_HAVE_TLS)
|
42
|
+
#define ABSL_PER_THREAD_TLS_KEYWORD __thread
|
43
|
+
#define ABSL_PER_THREAD_TLS 1
|
44
|
+
#elif defined(_MSC_VER)
|
45
|
+
#define ABSL_PER_THREAD_TLS_KEYWORD __declspec(thread)
|
46
|
+
#define ABSL_PER_THREAD_TLS 1
|
47
|
+
#else
|
48
|
+
#define ABSL_PER_THREAD_TLS_KEYWORD
|
49
|
+
#define ABSL_PER_THREAD_TLS 0
|
50
|
+
#endif
|
51
|
+
|
52
|
+
#endif // ABSL_BASE_INTERNAL_PER_THREAD_TLS_H_
|