MySQL 8.4.2
Source Code Documentation
event_scheduler.h
Go to the documentation of this file.
1#ifndef _EVENT_SCHEDULER_H_
2#define _EVENT_SCHEDULER_H_
3/* Copyright (c) 2004, 2024, Oracle and/or its affiliates.
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, version 2.0,
7 as published by the Free Software Foundation.
8
9 This program is designed to work with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have either included with
15 the program or referenced in the documentation.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25
26/**
27 @addtogroup Event_Scheduler
28 @{
29*/
30/**
31 @file
32
33 Declarations of the scheduler thread class
34 and related functionality.
35
36 This file is internal to Event_Scheduler module. Please do not
37 include it directly. All public declarations of Event_Scheduler
38 module are in events.h and event_data_objects.h.
39*/
40
41#include <sys/types.h>
42
43#include "my_inttypes.h"
47
49class Event_job_data;
50class Event_queue;
52class THD;
53
54void pre_init_event_thread(THD *thd);
55
57
58void deinit_event_thread(THD *thd);
59
61 public:
63
64 private:
65 void print_warnings(THD *thd, Event_job_data *et);
66};
67
69 public:
70 Event_scheduler(Event_queue *event_queue_arg);
72
73 /* State changing methods follow */
74
75 bool start(int *err_no);
76
77 bool stop();
78
79 /*
80 Need to be public because has to be called from the function
81 passed to my_thread_create.
82 */
83 bool run(THD *thd);
84
85 /* Information retrieving methods follow */
86 bool is_running();
87
89
90 private:
91 int workers_count();
92
93 /* helper functions */
95
96 /* helper functions for working with mutexes & conditionals */
97 void lock_data(const char *func, uint line);
98
99 void unlock_data(const char *func, uint line);
100
101 void cond_wait(THD *thd, struct timespec *abstime,
102 const PSI_stage_info *stage, const char *src_func,
103 const char *src_file, uint src_line);
104
106
108
109 /* This is the current status of the life-cycle of the scheduler. */
111
113
115
117
124
126
127 private:
128 // Disallow copy construction and assignment.
130 void operator=(Event_scheduler &) = delete;
131};
132
133/**
134 @} (End of group Event_Scheduler)
135*/
136
137#endif /* _EVENT_SCHEDULER_H_ */
Definition: event_db_repository.h:87
Definition: event_data_objects.h:157
Definition: event_data_objects.h:55
Queue of active events awaiting execution.
Definition: event_queue.h:102
Definition: event_scheduler.h:68
ulonglong started_events
Definition: event_scheduler.h:125
uint mutex_last_unlocked_at_line
Definition: event_scheduler.h:119
mysql_cond_t COND_state
Definition: event_scheduler.h:114
enum enum_state state
Definition: event_scheduler.h:110
bool waiting_on_cond
Definition: event_scheduler.h:123
void operator=(Event_scheduler &)=delete
const char * mutex_last_locked_in_func
Definition: event_scheduler.h:120
const char * mutex_last_unlocked_in_func
Definition: event_scheduler.h:121
uint mutex_last_locked_at_line
Definition: event_scheduler.h:118
THD * scheduler_thd
Definition: event_scheduler.h:112
Event_scheduler(const Event_scheduler &)=delete
Event_queue * queue
Definition: event_scheduler.h:116
mysql_mutex_t LOCK_scheduler_state
Definition: event_scheduler.h:105
bool mutex_scheduler_data_locked
Definition: event_scheduler.h:122
enum_state
Definition: event_scheduler.h:107
@ STOPPING
Definition: event_scheduler.h:107
@ INITIALIZED
Definition: event_scheduler.h:107
@ RUNNING
Definition: event_scheduler.h:107
Definition: event_scheduler.h:60
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
void dump_internal_status()
Definition: event_scheduler.cc:928
bool is_running()
Definition: event_scheduler.cc:728
void pre_init_event_thread(THD *thd)
Definition: event_scheduler.cc:213
bool stop()
Stops the scheduler (again).
Definition: event_scheduler.cc:750
void cond_wait(THD *thd, struct timespec *abstime, const PSI_stage_info *stage, const char *src_func, const char *src_file, uint src_line)
Definition: event_scheduler.cc:888
void run(THD *thd, Event_queue_element_for_exec *event)
Function that executes an event in a child thread.
Definition: event_scheduler.cc:348
void print_warnings(THD *thd, Event_job_data *et)
Definition: event_scheduler.cc:105
bool execute_top(Event_queue_element_for_exec *event_name)
Definition: event_scheduler.cc:661
void lock_data(const char *func, uint line)
Definition: event_scheduler.cc:848
bool run(THD *thd)
Definition: event_scheduler.cc:584
void deinit_event_thread(THD *thd)
Definition: event_scheduler.cc:187
void unlock_data(const char *func, uint line)
Definition: event_scheduler.cc:867
Event_scheduler(Event_queue *event_queue_arg)
Definition: event_scheduler.cc:452
int workers_count()
Definition: event_scheduler.cc:828
bool post_init_event_thread(THD *thd)
Definition: event_scheduler.cc:167
~Event_scheduler()
Definition: event_scheduler.cc:468
bool start(int *err_no)
Starts the scheduler (again).
Definition: event_scheduler.cc:488
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
Instrumentation helpers for conditions.
ABI for instrumented mutexes.
Performance schema instrumentation interface.
required string event
Definition: replication_group_member_actions.proto:32
Stage instrument information.
Definition: psi_stage_bits.h:74
An instrumented cond structure.
Definition: mysql_cond_bits.h:50
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:50