mysql_idle.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
  2. This program is free software; you can redistribute it and/or modify
  3. it under the terms of the GNU General Public License, version 2.0,
  4. as published by the Free Software Foundation.
  5. This program is also distributed with certain software (including
  6. but not limited to OpenSSL) that is licensed under separate terms,
  7. as designated in a particular file or component or in included license
  8. documentation. The authors of MySQL hereby grant you an additional
  9. permission to link the program and your derivative works with the
  10. separately licensed software that they have included with MySQL.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License, version 2.0, for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software Foundation,
  17. 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
  18. #ifndef MYSQL_IDLE_H
  19. #define MYSQL_IDLE_H
  20. /**
  21. @file mysql/psi/mysql_idle.h
  22. Instrumentation helpers for idle waits.
  23. */
  24. #include "mysql/psi/psi.h"
  25. #ifndef PSI_IDLE_CALL
  26. #define PSI_IDLE_CALL(M) PSI_DYNAMIC_CALL(M)
  27. #endif
  28. /**
  29. @defgroup Idle_instrumentation Idle Instrumentation
  30. @ingroup Instrumentation_interface
  31. @{
  32. */
  33. /**
  34. @def MYSQL_START_IDLE_WAIT
  35. Instrumentation helper for table io_waits.
  36. This instrumentation marks the start of a wait event.
  37. @param LOCKER the locker
  38. @param STATE the locker state
  39. @sa MYSQL_END_IDLE_WAIT.
  40. */
  41. #ifdef HAVE_PSI_IDLE_INTERFACE
  42. #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
  43. LOCKER= inline_mysql_start_idle_wait(STATE, __FILE__, __LINE__)
  44. #else
  45. #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
  46. do {} while (0)
  47. #endif
  48. /**
  49. @def MYSQL_END_IDLE_WAIT
  50. Instrumentation helper for idle waits.
  51. This instrumentation marks the end of a wait event.
  52. @param LOCKER the locker
  53. @sa MYSQL_START_IDLE_WAIT.
  54. */
  55. #ifdef HAVE_PSI_IDLE_INTERFACE
  56. #define MYSQL_END_IDLE_WAIT(LOCKER) \
  57. inline_mysql_end_idle_wait(LOCKER)
  58. #else
  59. #define MYSQL_END_IDLE_WAIT(LOCKER) \
  60. do {} while (0)
  61. #endif
  62. #ifdef HAVE_PSI_IDLE_INTERFACE
  63. /**
  64. Instrumentation calls for MYSQL_START_IDLE_WAIT.
  65. @sa MYSQL_END_IDLE_WAIT.
  66. */
  67. static inline struct PSI_idle_locker *
  68. inline_mysql_start_idle_wait(PSI_idle_locker_state *state,
  69. const char *src_file, int src_line)
  70. {
  71. struct PSI_idle_locker *locker;
  72. locker= PSI_IDLE_CALL(start_idle_wait)(state, src_file, src_line);
  73. return locker;
  74. }
  75. /**
  76. Instrumentation calls for MYSQL_END_IDLE_WAIT.
  77. @sa MYSQL_START_IDLE_WAIT.
  78. */
  79. static inline void
  80. inline_mysql_end_idle_wait(struct PSI_idle_locker *locker)
  81. {
  82. if (likely(locker != NULL))
  83. PSI_IDLE_CALL(end_idle_wait)(locker);
  84. }
  85. #endif
  86. /** @} (end of group Idle_instrumentation) */
  87. #endif