1 #ifndef INCLUDES_MYSQL_INSTANCE_MANAGER_GUARDIAN_H
2 #define INCLUDES_MYSQL_INSTANCE_MANAGER_GUARDIAN_H
3 /* Copyright (c) 2004-2006 MySQL AB
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.
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.
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
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
19 #include <my_global.h>
23 #include "thread_registry.h"
25 #if defined(__GNUC__) && defined(USE_PRAGMA_INTERFACE)
31 class Thread_registry
;
34 The guardian thread is responsible for monitoring and restarting of guarded
38 class Guardian
: public Thread
41 Guardian(Thread_registry
*thread_registry_arg
,
42 Instance_map
*instance_map_arg
);
48 void request_shutdown();
61 void stop_instances();
63 void process_instance(Instance
*instance
);
67 LOCK_guardian protectes the members in this section:
71 Also, it is used for COND_guardian.
73 pthread_mutex_t LOCK_guardian
;
76 Guardian's main loop waits on this condition. So, it should be signalled
77 each time, when instance state has been changed and we want Guardian to
80 TODO: Change this to having data-scoped conditions, i.e. conditions,
81 which indicate that some data has been changed.
83 pthread_cond_t COND_guardian
;
86 This variable is set to TRUE, when Manager thread is shutting down.
87 The flag is used by Guardian thread to understand that it's time to
90 bool shutdown_requested
;
93 This flag is set to TRUE on shutdown by Guardian thread, when all guarded
96 The flag is used in the Manager thread to wait for Guardian to stop all
101 Thread_info thread_info
;
102 Thread_registry
*thread_registry
;
103 Instance_map
*instance_map
;
106 Guardian(const Guardian
&);
107 Guardian
&operator =(const Guardian
&);
110 #endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_GUARDIAN_H */