block_annotate.h 2.0 KB

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