Debian Codegraph @

src/core/lib/iomgr/block_annotate.h

raw
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 #ifndef GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H
20 #define GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H
21
22 void gpr_thd_start_blocking_region();
23 void gpr_thd_end_blocking_region();
24
25 /* These annotations identify the beginning and end of regions where
26 the code may block for reasons other than synchronization functions.
27 These include poll, epoll, and getaddrinfo. */
28
29 #ifdef GRPC_SCHEDULING_MARK_BLOCKING_REGION
30 #define GRPC_SCHEDULING_START_BLOCKING_REGION \
31 do { \
32 gpr_thd_start_blocking_region(); \
33 } while (0)
34 #define GRPC_SCHEDULING_END_BLOCKING_REGION \
35 do { \
36 gpr_thd_end_blocking_region(); \
37 grpc_core::ExecCtx::Get()->InvalidateNow(); \
38 } while (0)
39 #define GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX \
40 do { \
41 gpr_thd_end_blocking_region(); \
42 } while (0)
43
44 #else
45 #define GRPC_SCHEDULING_START_BLOCKING_REGION \
46 do { \
47 } while (0)
48 #define GRPC_SCHEDULING_END_BLOCKING_REGION \
49 do { \
50 grpc_core::ExecCtx::Get()->InvalidateNow(); \
51 } while (0)
52 #define GRPC_SCHEDULING_END_BLOCKING_REGION_NO_EXEC_CTX \
53 do { \
54 } while (0)
55 #endif
56
57 #endif /* GRPC_CORE_LIB_IOMGR_BLOCK_ANNOTATE_H */