MySQL 8.1.0
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, 2023, 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 also distributed 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 included with MySQL.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24
25/**
26 @addtogroup Event_Scheduler
27 @{
28*/
29/**
30 @file
31
32 Declarations of the scheduler thread class
33 and related functionality.
34
35 This file is internal to Event_Scheduler module. Please do not
36 include it directly. All public declarations of Event_Scheduler
37 module are in events.h and event_data_objects.h.
38*/
39
40#include <sys/types.h>
41
42#include "my_inttypes.h"
46
48class Event_job_data;
49class Event_queue;
51class THD;
52
53void pre_init_event_thread(THD *thd);
54
56
57void deinit_event_thread(THD *thd);
58
60 public:
62
63 private:
64 void print_warnings(THD *thd, Event_job_data *et);
65};
66
68 public:
69 Event_scheduler(Event_queue *event_queue_arg);
71
72 /* State changing methods follow */
73
74 bool start(int *err_no);
75
76 bool stop();
77
78 /*
79 Need to be public because has to be called from the function
80 passed to my_thread_create.
81 */
82 bool run(THD *thd);
83
84 /* Information retrieving methods follow */
85 bool is_running();
86
88
89 private:
90 int workers_count();
91
92 /* helper functions */
94
95 /* helper functions for working with mutexes & conditionals */
96 void lock_data(const char *func, uint line);
97
98 void unlock_data(const char *func, uint line);
99
100 void cond_wait(THD *thd, struct timespec *abstime,
101 const PSI_stage_info *stage, const char *src_func,
102 const char *src_file, uint src_line);
103
105
107
108 /* This is the current status of the life-cycle of the scheduler. */
110
112
114
116
123
125
126 private:
127 // Disallow copy construction and assignment.
129 void operator=(Event_scheduler &) = delete;
130};
131
132/**
133 @} (End of group Event_Scheduler)
134*/
135
136#endif /* _EVENT_SCHEDULER_H_ */
Definition: event_db_repository.h:86
Definition: event_data_objects.h:155
Definition: event_data_objects.h:53
Queue of active events awaiting execution.
Definition: event_queue.h:101
Definition: event_scheduler.h:67
ulonglong started_events
Definition: event_scheduler.h:124
uint mutex_last_unlocked_at_line
Definition: event_scheduler.h:118
mysql_cond_t COND_state
Definition: event_scheduler.h:113
enum enum_state state
Definition: event_scheduler.h:109
bool waiting_on_cond
Definition: event_scheduler.h:122
void operator=(Event_scheduler &)=delete
const char * mutex_last_locked_in_func
Definition: event_scheduler.h:119
const char * mutex_last_unlocked_in_func
Definition: event_scheduler.h:120
uint mutex_last_locked_at_line
Definition: event_scheduler.h:117
THD * scheduler_thd
Definition: event_scheduler.h:111
Event_scheduler(const Event_scheduler &)=delete
Event_queue * queue
Definition: event_scheduler.h:115
mysql_mutex_t LOCK_scheduler_state
Definition: event_scheduler.h:104
bool mutex_scheduler_data_locked
Definition: event_scheduler.h:121
enum_state
Definition: event_scheduler.h:106
@ STOPPING
Definition: event_scheduler.h:106
@ INITIALIZED
Definition: event_scheduler.h:106
@ RUNNING
Definition: event_scheduler.h:106
Definition: event_scheduler.h:59
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
void dump_internal_status()
Definition: event_scheduler.cc:927
bool is_running()
Definition: event_scheduler.cc:727
void pre_init_event_thread(THD *thd)
Definition: event_scheduler.cc:212
bool stop()
Stops the scheduler (again).
Definition: event_scheduler.cc:749
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:887
void run(THD *thd, Event_queue_element_for_exec *event)
Function that executes an event in a child thread.
Definition: event_scheduler.cc:347
void print_warnings(THD *thd, Event_job_data *et)
Definition: event_scheduler.cc:104
bool execute_top(Event_queue_element_for_exec *event_name)
Definition: event_scheduler.cc:660
void lock_data(const char *func, uint line)
Definition: event_scheduler.cc:847
bool run(THD *thd)
Definition: event_scheduler.cc:583
void deinit_event_thread(THD *thd)
Definition: event_scheduler.cc:186
void unlock_data(const char *func, uint line)
Definition: event_scheduler.cc:866
Event_scheduler(Event_queue *event_queue_arg)
Definition: event_scheduler.cc:451
int workers_count()
Definition: event_scheduler.cc:827
bool post_init_event_thread(THD *thd)
Definition: event_scheduler.cc:166
~Event_scheduler()
Definition: event_scheduler.cc:467
bool start(int *err_no)
Starts the scheduler (again).
Definition: event_scheduler.cc:487
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
Instrumentation helpers for conditions.
ABI for instrumented mutexes.
Performance schema instrumentation interface.
required string event
Definition: replication_group_member_actions.proto:31
Stage instrument information.
Definition: psi_stage_bits.h:73
An instrumented cond structure.
Definition: mysql_cond_bits.h:49
An instrumented mutex structure.
Definition: mysql_mutex_bits.h:49