MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
event_queue.h
Go to the documentation of this file.
1 #ifndef _EVENT_QUEUE_H_
2 #define _EVENT_QUEUE_H_
3 /* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; version 2 of the License.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, write to the Free Software Foundation,
16  51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */
17 
28 #ifdef HAVE_PSI_INTERFACE
29 extern PSI_mutex_key key_LOCK_event_queue;
30 extern PSI_cond_key key_COND_queue_state;
31 #endif /* HAVE_PSI_INTERFACE */
32 
33 #include "queues.h" // QUEUE
34 #include "sql_string.h" /* LEX_STRING */
35 #include "my_time.h" /* my_time_t, interval_type */
36 
37 class Event_basic;
40 
41 class THD;
42 
48 {
49 public:
50  Event_queue();
51  ~Event_queue();
52 
53  bool
54  init_queue(THD *thd);
55 
56  /* Methods for queue management follow */
57 
58  bool
59  create_event(THD *thd, Event_queue_element *new_element,
60  bool *created);
61 
62  void
63  update_event(THD *thd, LEX_STRING dbname, LEX_STRING name,
64  Event_queue_element *new_element);
65 
66  void
67  drop_event(THD *thd, LEX_STRING dbname, LEX_STRING name);
68 
69  void
70  drop_schema_events(THD *thd, LEX_STRING schema);
71 
72  void
73  recalculate_activation_times(THD *thd);
74 
75  bool
76  get_top_for_execution_if_time(THD *thd,
77  Event_queue_element_for_exec **event_name);
78 
79 
80  void
81  dump_internal_status();
82 
83 private:
84  void
85  empty_queue();
86 
87  void
88  deinit_queue();
89  /* helper functions for working with mutexes & conditionals */
90  void
91  lock_data(const char *func, uint line);
92 
93  void
94  unlock_data(const char *func, uint line);
95 
96  void
97  cond_wait(THD *thd, struct timespec *abstime, const PSI_stage_info *stage,
98  const char *src_func, const char *src_file, uint src_line);
99 
100  void
101  find_n_remove_event(LEX_STRING db, LEX_STRING name);
102 
103 
104  void
105  drop_matching_events(THD *thd, LEX_STRING pattern,
106  bool (*)(LEX_STRING, Event_basic *));
107 
108 
109  void
110  dbug_dump_queue(time_t now);
111 
112  /* LOCK_event_queue is the mutex which protects the access to the queue. */
113  mysql_mutex_t LOCK_event_queue;
114  mysql_cond_t COND_queue_state;
115 
116  /* The sorted queue with the Event_queue_element objects */
117  QUEUE queue;
118 
119  my_time_t next_activation_at;
120 
121  uint mutex_last_locked_at_line;
122  uint mutex_last_unlocked_at_line;
123  uint mutex_last_attempted_lock_at_line;
124  const char* mutex_last_locked_in_func;
125  const char* mutex_last_unlocked_in_func;
126  const char* mutex_last_attempted_lock_in_func;
127  bool mutex_queue_data_locked;
128  bool mutex_queue_data_attempting_lock;
129  bool waiting_on_cond;
130 };
135 #endif /* _EVENT_QUEUE_H_ */