mysql_idle.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* Copyright (c) 2011, 2012, 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 as published by
  4. the Free Software Foundation; version 2 of the License.
  5. This program is distributed in the hope that it will be useful,
  6. but WITHOUT ANY WARRANTY; without even the implied warranty of
  7. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  8. GNU General Public License for more details.
  9. You should have received a copy of the GNU General Public License
  10. along with this program; if not, write to the Free Software Foundation,
  11. 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
  12. #ifndef MYSQL_IDLE_H
  13. #define MYSQL_IDLE_H
  14. /**
  15. @file mysql/psi/mysql_idle.h
  16. Instrumentation helpers for idle waits.
  17. */
  18. #include "mysql/psi/psi.h"
  19. /**
  20. @defgroup Idle_instrumentation Idle Instrumentation
  21. @ingroup Instrumentation_interface
  22. @{
  23. */
  24. /**
  25. @def MYSQL_START_IDLE_WAIT
  26. Instrumentation helper for table io_waits.
  27. This instrumentation marks the start of a wait event.
  28. @param LOCKER the locker
  29. @param STATE the locker state
  30. @sa MYSQL_END_IDLE_WAIT.
  31. */
  32. #ifdef HAVE_PSI_IDLE_INTERFACE
  33. #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
  34. LOCKER= inline_mysql_start_idle_wait(STATE, __FILE__, __LINE__)
  35. #else
  36. #define MYSQL_START_IDLE_WAIT(LOCKER, STATE) \
  37. do {} while (0)
  38. #endif
  39. /**
  40. @def MYSQL_END_IDLE_WAIT
  41. Instrumentation helper for idle waits.
  42. This instrumentation marks the end of a wait event.
  43. @param LOCKER the locker
  44. @sa MYSQL_START_IDLE_WAIT.
  45. */
  46. #ifdef HAVE_PSI_IDLE_INTERFACE
  47. #define MYSQL_END_IDLE_WAIT(LOCKER) \
  48. inline_mysql_end_idle_wait(LOCKER)
  49. #else
  50. #define MYSQL_END_IDLE_WAIT(LOCKER) \
  51. do {} while (0)
  52. #endif
  53. #ifdef HAVE_PSI_IDLE_INTERFACE
  54. /**
  55. Instrumentation calls for MYSQL_START_IDLE_WAIT.
  56. @sa MYSQL_END_IDLE_WAIT.
  57. */
  58. static inline struct PSI_idle_locker *
  59. inline_mysql_start_idle_wait(PSI_idle_locker_state *state,
  60. const char *src_file, int src_line)
  61. {
  62. struct PSI_idle_locker *locker;
  63. locker= PSI_IDLE_CALL(start_idle_wait)(state, src_file, src_line);
  64. return locker;
  65. }
  66. /**
  67. Instrumentation calls for MYSQL_END_IDLE_WAIT.
  68. @sa MYSQL_START_IDLE_WAIT.
  69. */
  70. static inline void
  71. inline_mysql_end_idle_wait(struct PSI_idle_locker *locker)
  72. {
  73. if (likely(locker != NULL))
  74. PSI_IDLE_CALL(end_idle_wait)(locker);
  75. }
  76. #endif
  77. /** @} (end of group Idle_instrumentation) */
  78. #endif