浏览代码

Update block_annotate.h

yang-g 8 年之前
父节点
当前提交
0f9e1932a3
共有 1 个文件被更改,包括 22 次插入0 次删除
  1. 22 0
      src/core/lib/support/block_annotate.h

+ 22 - 0
src/core/lib/support/block_annotate.h

@@ -19,15 +19,37 @@
 #ifndef GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H
 #ifndef GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H
 #define GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H
 #define GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H
 
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void gpr_thd_start_blocking_region();
+void gpr_thd_end_blocking_region();
+
+#ifdef __cplusplus
+}
+#endif
+
 /* These annotations identify the beginning and end of regions where
 /* These annotations identify the beginning and end of regions where
    the code may block for reasons other than synchronization functions.
    the code may block for reasons other than synchronization functions.
    These include poll, epoll, and getaddrinfo. */
    These include poll, epoll, and getaddrinfo. */
 
 
+#ifdef GRPC_SCHEDULING_MARK_BLOCKING_REGION
+#define GRPC_SCHEDULING_START_BLOCKING_REGION \
+  do {                                        \
+    gpr_thd_start_blocking_region();          \
+  } while (0)
+#define GRPC_SCHEDULING_END_BLOCKING_REGION \
+  do {                                      \
+    gpr_thd_end_blocking_region();          \
+  } while (0)
+#else
 #define GRPC_SCHEDULING_START_BLOCKING_REGION \
 #define GRPC_SCHEDULING_START_BLOCKING_REGION \
   do {                                        \
   do {                                        \
   } while (0)
   } while (0)
 #define GRPC_SCHEDULING_END_BLOCKING_REGION \
 #define GRPC_SCHEDULING_END_BLOCKING_REGION \
   do {                                      \
   do {                                      \
   } while (0)
   } while (0)
+#endif
 
 
 #endif /* GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H */
 #endif /* GRPC_CORE_LIB_SUPPORT_BLOCK_ANNOTATE_H */