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 #include <grpc/support/port_platform.h>
16 
17 #include "src/core/lib/event_engine/shim.h"
18 
19 #include "src/core/lib/experiments/experiments.h"
20 #include "src/core/lib/iomgr/port.h"
21 
22 namespace grpc_event_engine {
23 namespace experimental {
24 
25 #if defined(GRPC_POSIX_SOCKET_TCP) && !defined(GRPC_CFSTREAM)
26 bool g_event_engine_supports_fd = true;
27 #else
28 bool g_event_engine_supports_fd = false;
29 #endif
30 
UseEventEngineClient()31 bool UseEventEngineClient() {
32 // TODO(hork, eryu): Adjust the ifdefs accordingly when event engines become
33 // available for other platforms.
34 #if defined(GRPC_POSIX_SOCKET_TCP) && !defined(GRPC_CFSTREAM)
35   return grpc_core::IsEventEngineClientEnabled();
36 #elif defined(GPR_WINDOWS)
37   return grpc_core::IsEventEngineClientEnabled();
38 #elif defined(GRPC_IOS_EVENT_ENGINE_CLIENT)
39   return true;
40 #else
41   return false;
42 #endif
43 }
44 
UseEventEngineListener()45 bool UseEventEngineListener() {
46 // TODO(hork, eryu): Adjust the ifdefs accordingly when event engines become
47 // available for other platforms.
48 #if defined(GRPC_POSIX_SOCKET_TCP) && !defined(GRPC_CFSTREAM)
49   return grpc_core::IsEventEngineListenerEnabled();
50 #else
51   return false;
52 #endif
53 }
54 
EventEngineSupportsFd()55 bool EventEngineSupportsFd() {
56 #if defined(GRPC_POSIX_SOCKET_TCP) && !defined(GRPC_CFSTREAM)
57   return g_event_engine_supports_fd;
58 #else
59   return false;
60 #endif
61 }
62 
63 }  // namespace experimental
64 }  // namespace grpc_event_engine
65