summaryrefslogtreecommitdiff
path: root/sql/event_scheduler.h
diff options
context:
space:
mode:
authorunknown <andrey@lmy004.>2006-07-12 10:37:30 +0200
committerunknown <andrey@lmy004.>2006-07-12 10:37:30 +0200
commit628be8a71611bc86f7f0cf809b27d63bdd9b12c8 (patch)
tree1efc1513a721e18e2fa1fe76b14936f2d9e2d603 /sql/event_scheduler.h
parent42a8e2c9421854710679a0f6c3ceef6c0777ded4 (diff)
downloadmariadb-git-628be8a71611bc86f7f0cf809b27d63bdd9b12c8.tar.gz
WL#3337 (Event scheduler new architecture)
event_scheduler_ng.cc/h is no more BitKeeper/deleted/.del-event_scheduler_ng.cc~8896b89040dbc4f6: Delete: sql/event_scheduler_ng.cc BitKeeper/deleted/.del-event_scheduler_ng.h~1431af5b185376f: Delete: sql/event_scheduler_ng.h mysql-test/r/not_embedded_server.result: fix test sql/Makefile.am: event_scheduler_ng.cc/h is no more sql/event_queue.cc: event_scheduler_ng.cc/h is no more sql/event_queue.h: event_scheduler_ng.cc/h is no more sql/event_scheduler.cc: event_scheduler_ng.cc/h is no more sql/event_scheduler.h: event_scheduler_ng.cc/h is no more sql/events.cc: event_scheduler_ng.cc/h is no more sql/events.h: event_scheduler_ng.cc/h is no more
Diffstat (limited to 'sql/event_scheduler.h')
-rw-r--r--sql/event_scheduler.h104
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_ */