wakeup_fd_posix.cc
Go to the documentation of this file.
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 
20 
22 
23 #ifdef GRPC_POSIX_WAKEUP_FD
24 
25 #include <stddef.h>
26 
29 
30 static const grpc_wakeup_fd_vtable* wakeup_fd_vtable = nullptr;
31 
34 
35 static int has_real_wakeup_fd = 1;
36 
37 static gpr_once once_init_wakeup_fd = GPR_ONCE_INIT;
38 
39 void grpc_wakeup_fd_global_init(void) {
40  gpr_once_init(&once_init_wakeup_fd, []() {
43  wakeup_fd_vtable = &grpc_specialized_wakeup_fd_vtable;
44  } else if (grpc_allow_pipe_wakeup_fd &&
46  wakeup_fd_vtable = &grpc_pipe_wakeup_fd_vtable;
47  } else {
48  has_real_wakeup_fd = 0;
49  }
50  });
51 }
52 
54 
55 int grpc_has_wakeup_fd(void) { return has_real_wakeup_fd; }
56 
58  return wakeup_fd_vtable->init(fd_info);
59 }
60 
62  return wakeup_fd_vtable->consume(fd_info);
63 }
64 
66  return wakeup_fd_vtable->wakeup(fd_info);
67 }
68 
70  wakeup_fd_vtable->destroy(fd_info);
71 }
72 
73 #endif /* GRPC_POSIX_WAKEUP_FD */
grpc_wakeup_fd_destroy
void grpc_wakeup_fd_destroy(grpc_wakeup_fd *fd_info)
grpc_specialized_wakeup_fd_vtable
const grpc_wakeup_fd_vtable grpc_specialized_wakeup_fd_vtable
wakeup_fd_posix.h
gpr_once
pthread_once_t gpr_once
Definition: impl/codegen/sync_posix.h:50
grpc_wakeup_fd
Definition: wakeup_fd_posix.h:74
GPR_ONCE_INIT
#define GPR_ONCE_INIT
Definition: impl/codegen/sync_posix.h:52
grpc_wakeup_fd_vtable::init
grpc_error_handle(* init)(grpc_wakeup_fd *fd_info)
Definition: wakeup_fd_posix.h:66
gpr_once_init
GPRAPI void gpr_once_init(gpr_once *once, void(*init_function)(void))
wakeup_fd_pipe.h
grpc_wakeup_fd_vtable::wakeup
grpc_error_handle(* wakeup)(grpc_wakeup_fd *fd_info)
Definition: wakeup_fd_posix.h:68
grpc_wakeup_fd_wakeup
grpc_error_handle grpc_wakeup_fd_wakeup(grpc_wakeup_fd *fd_info) GRPC_MUST_USE_RESULT
grpc_wakeup_fd_vtable::check_availability
int(* check_availability)(void)
Definition: wakeup_fd_posix.h:71
grpc_wakeup_fd_init
grpc_error_handle grpc_wakeup_fd_init(grpc_wakeup_fd *fd_info) GRPC_MUST_USE_RESULT
grpc_wakeup_fd_consume_wakeup
grpc_error_handle grpc_wakeup_fd_consume_wakeup(grpc_wakeup_fd *fd_info) GRPC_MUST_USE_RESULT
grpc_wakeup_fd_vtable::consume
grpc_error_handle(* consume)(grpc_wakeup_fd *fd_info)
Definition: wakeup_fd_posix.h:67
grpc_allow_specialized_wakeup_fd
int grpc_allow_specialized_wakeup_fd
grpc_wakeup_fd_global_init
void grpc_wakeup_fd_global_init(void)
port.h
grpc_has_wakeup_fd
int grpc_has_wakeup_fd(void)
grpc_wakeup_fd_global_destroy
void grpc_wakeup_fd_global_destroy(void)
grpc_error
Definition: error_internal.h:42
grpc_wakeup_fd_vtable::destroy
void(* destroy)(grpc_wakeup_fd *fd_info)
Definition: wakeup_fd_posix.h:69
grpc_pipe_wakeup_fd_vtable
const grpc_wakeup_fd_vtable grpc_pipe_wakeup_fd_vtable
grpc_wakeup_fd_vtable
Definition: wakeup_fd_posix.h:65
if
if(p->owned &&p->wrapped !=NULL)
Definition: call.c:42
grpc_allow_pipe_wakeup_fd
int grpc_allow_pipe_wakeup_fd
port_platform.h


grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:52