service_thread_scheduler.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
  3. This program is free software; you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License, version 2.0,
  5. as published by the Free Software Foundation.
  6. This program is also distributed with certain software (including
  7. but not limited to OpenSSL) that is licensed under separate terms,
  8. as designated in a particular file or component or in included license
  9. documentation. The authors of MySQL hereby grant you an additional
  10. permission to link the program and your derivative works with the
  11. separately licensed software that they have included with MySQL.
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. GNU General Public License, version 2.0, for more details.
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef SERVICE_THREAD_SCHEDULER_INCLUDED
  21. #define SERVICE_THREAD_SCHEDULER_INCLUDED
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. struct Connection_handler_functions;
  26. struct THD_event_functions;
  27. extern struct my_thread_scheduler_service {
  28. int (*connection_handler_set)(struct Connection_handler_functions *,
  29. struct THD_event_functions *);
  30. int (*connection_handler_reset)();
  31. } *my_thread_scheduler_service;
  32. #ifdef MYSQL_DYNAMIC_PLUGIN
  33. #define my_connection_handler_set(F, M) \
  34. my_thread_scheduler_service->connection_handler_set((F), (M))
  35. #define my_connection_handler_reset() \
  36. my_thread_scheduler_service->connection_handler_reset()
  37. #else
  38. /**
  39. Instantiates Plugin_connection_handler based on the supplied
  40. Conection_handler_functions and sets it as the current
  41. connection handler.
  42. Also sets the THD_event_functions functions which will
  43. be called by the server when e.g. begining a wait.
  44. Remembers the existing connection handler so that it can be restored later.
  45. @param chf struct with functions to be called when e.g. handling
  46. new clients.
  47. @param tef struct with functions to be called when events
  48. (e.g. lock wait) happens.
  49. @note Both pointers (i.e. not the structs themselves) will be copied,
  50. so the structs must not disappear.
  51. @note We don't support dynamically loading more than one connection handler.
  52. @retval 1 failure
  53. @retval 0 success
  54. */
  55. int my_connection_handler_set(struct Connection_handler_functions *chf,
  56. struct THD_event_functions *tef);
  57. /**
  58. Destroys the current connection handler and restores the previous.
  59. Should only be called after calling my_connection_handler_set().
  60. @retval 1 failure
  61. @retval 0 success
  62. */
  63. int my_connection_handler_reset();
  64. #endif /* MYSQL_DYNAMIC_PLUGIN */
  65. #ifdef __cplusplus
  66. }
  67. #endif
  68. #endif /* SERVICE_THREAD_SCHEDULER_INCLUDED */