37 #ifdef GRPC_CFSTREAM_IOMGR
50 static const char* grpc_cfstream_env_var =
"grpc_cfstream";
51 static const char* grpc_cfstream_run_loop_env_var =
"GRPC_CFSTREAM_RUN_LOOP";
62 static void apple_iomgr_platform_flush(
void) {}
64 static void apple_iomgr_platform_shutdown(
void) {
68 static void apple_iomgr_platform_shutdown_background_closure(
void) {}
70 static bool apple_iomgr_platform_is_any_background_poller_thread(
void) {
74 static bool apple_iomgr_platform_add_closure_to_background_poller(
80 apple_iomgr_platform_init,
81 apple_iomgr_platform_flush,
82 apple_iomgr_platform_shutdown,
83 apple_iomgr_platform_shutdown_background_closure,
84 apple_iomgr_platform_is_any_background_poller_thread,
85 apple_iomgr_platform_add_closure_to_background_poller};
90 bool enable_cfstream_run_loop;
94 CFStreamEnv ParseEnvForCFStream() {
96 char* enable_cfstream_str =
getenv(grpc_cfstream_env_var);
98 enable_cfstream_str ==
nullptr || enable_cfstream_str[0] !=
'0';
99 char* enable_cfstream_run_loop_str =
getenv(grpc_cfstream_run_loop_env_var);
102 env.enable_cfstream_run_loop = enable_cfstream_run_loop_str !=
nullptr &&
103 enable_cfstream_run_loop_str[0] ==
'1';
107 void MaybeInitializeTcpPosix(
void) {
108 CFStreamEnv
env = ParseEnvForCFStream();
109 if (!
env.enable_cfstream || !
env.enable_cfstream_run_loop) {
110 grpc_tcp_posix_init();
114 void MaybeShutdownTcpPosix(
void) {
115 CFStreamEnv
env = ParseEnvForCFStream();
116 if (!
env.enable_cfstream || !
env.enable_cfstream_run_loop) {
117 grpc_tcp_posix_shutdown();
122 static void iomgr_platform_init(
void) {
123 MaybeInitializeTcpPosix();
128 static void iomgr_platform_flush(
void) {}
130 static void iomgr_platform_shutdown(
void) {
133 MaybeShutdownTcpPosix();
136 static void iomgr_platform_shutdown_background_closure(
void) {
140 static bool iomgr_platform_is_any_background_poller_thread(
void) {
144 static bool iomgr_platform_add_closure_to_background_poller(
151 iomgr_platform_flush,
152 iomgr_platform_shutdown,
153 iomgr_platform_shutdown_background_closure,
154 iomgr_platform_is_any_background_poller_thread,
155 iomgr_platform_add_closure_to_background_poller};
158 CFStreamEnv
env = ParseEnvForCFStream();
159 if (!
env.enable_cfstream) {
166 }
else if (
env.enable_cfstream && !
env.enable_cfstream_run_loop) {
186 char* enable_cfstream_str =
getenv(grpc_cfstream_env_var);
187 bool enable_cfstream =
188 enable_cfstream_str ==
nullptr || enable_cfstream_str[0] !=
'0';
189 char* enable_cfstream_run_loop_str =
getenv(grpc_cfstream_run_loop_env_var);
192 bool enable_cfstream_run_loop = enable_cfstream_run_loop_str !=
nullptr &&
193 enable_cfstream_run_loop_str[0] ==
'1';
194 if (enable_cfstream && enable_cfstream_run_loop) {