diff options
author | andrey@lmy004. <> | 2006-07-12 10:37:30 +0200 |
---|---|---|
committer | andrey@lmy004. <> | 2006-07-12 10:37:30 +0200 |
commit | 3f4e1f5c695215cd18222c359fa56eea4ab63664 (patch) | |
tree | 1efc1513a721e18e2fa1fe76b14936f2d9e2d603 /sql/event_scheduler.h | |
parent | 0d517461f0e6b465e0d7f9bc4a5b9241f7cbb657 (diff) | |
download | mariadb-git-3f4e1f5c695215cd18222c359fa56eea4ab63664.tar.gz |
WL#3337 (Event scheduler new architecture)
event_scheduler_ng.cc/h is no more
Diffstat (limited to 'sql/event_scheduler.h')
-rw-r--r-- | sql/event_scheduler.h | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/sql/event_scheduler.h b/sql/event_scheduler.h index acd0debe391..bf3e8e63e11 100644 --- a/sql/event_scheduler.h +++ b/sql/event_scheduler.h @@ -16,4 +16,108 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +class Event_queue; +class Event_job_data; + +class Event_scheduler +{ +public: + Event_scheduler(){} + ~Event_scheduler(){} + + enum enum_state + { + INITIALIZED = 0, + RUNNING, + STOPPING + }; + + /* State changing methods follow */ + + bool + start(); + + bool + stop(); + + /* + Need to be public because has to be called from the function + passed to pthread_create. + */ + bool + run(THD *thd); + + bool + init_scheduler(Event_queue *queue); + + void + deinit_scheduler(); + + void + init_mutexes(); + + void + deinit_mutexes(); + + /* Information retrieving methods follow */ + + enum enum_state + get_state(); + + void + queue_changed(); + + bool + dump_internal_status(THD *thd); + +private: + uint + workers_count(); + + /* helper functions */ + bool + execute_top(THD *thd, Event_job_data *job_data); + + /* helper functions for working with mutexes & conditionals */ + void + lock_data(const char *func, uint line); + + void + unlock_data(const char *func, uint line); + + void + cond_wait(struct timespec *abstime, const char *func, uint line); + + pthread_mutex_t LOCK_scheduler_state; + + /* This is the current status of the life-cycle of the scheduler. */ + enum enum_state state; + + /* + Holds the thread id of the executor thread or 0 if the scheduler is not + running. It is used by ::shutdown() to know which thread to kill with + kill_one_thread(). The latter wake ups a thread if it is waiting on a + conditional variable and sets thd->killed to non-zero. + */ + ulong thread_id; + + pthread_cond_t COND_state; + + Event_queue *queue; + + uint mutex_last_locked_at_line; + uint mutex_last_unlocked_at_line; + const char* mutex_last_locked_in_func; + const char* mutex_last_unlocked_in_func; + bool mutex_scheduler_data_locked; + bool waiting_on_cond; + + ulonglong started_events; + +private: + /* Prevent use of these */ + Event_scheduler(const Event_scheduler &); + void operator=(Event_scheduler &); +}; + #endif /* _EVENT_SCHEDULER_H_ */ |