diff options
author | unknown <andrey@fifo.vaih.whnetz> | 2006-08-31 17:18:39 +0200 |
---|---|---|
committer | unknown <andrey@fifo.vaih.whnetz> | 2006-08-31 17:18:39 +0200 |
commit | 0410cc3a0c87582fe9d749f5e007dcdb1b9848e1 (patch) | |
tree | 7578f63a766b0ce331cbafad99ef748c185822f1 /sql/event_scheduler.h | |
parent | 3e4b79d9cafea4d1e86ddba6c8f5658f4c4ef23c (diff) | |
download | mariadb-git-0410cc3a0c87582fe9d749f5e007dcdb1b9848e1.tar.gz |
WL#3337 (Event scheduler new architecture)
This patch makes the relationship between Event_scheduler and Event_queue
unidirectional from the former to the latter.
The change is that the conditional on which the scheduler sleeped has been
moved to the Event_queue and the latter does not call anymore
Event_scheduler::queue_changed(), which in turn has be removed.
sql/event_queue.cc:
Remove dependency of Event_queue on Event_scheduler but not vice versa.
Event_scheduler polls whether there is time to execute an event.
Removed notify_observers() as the way of calling has changed.
Added Event_queue::cond_wait() similar to Event_scheduler::cond_wait().
sql/event_queue.h:
init_queue() does not need anymore Event_scheduler object because
the relationship is now one-way. Event_scheduler knows about Event_queue
but not vice versa.
get_top_execution_if_time() does by itself the waiting instead of
returning abstime. This simplifies the code in Event_scheduler::run()
get_top_execution_if_time() returns only if job_data != NULL or if
the scheduler thread was killed.
notify_observers() is no more used and therefore removed.
Added Event_queue::cond_wait() because now there is waiting on a
conditional variable in Event_queue too (like in Event_scheduler for
::stop()).
sql/event_scheduler.cc:
Change the relationship between Event_scheduler & Event_queue.
Event_queue does not know anymore about Event_scheduler. When
the scheduler calls get_top_element_if_time() it may fall asleep
on a conditional of Event_queue, if either the queue is empty or
it's still not time for activation. When the method returns it
will return a non-null address, namely an object to be executed.
If the return value is NULL, the thread was killed by a call to
Event_scheduler::stop() (we assert this).
sql/event_scheduler.h:
Remove queue_changed() as it is obsoleted by making the relationship
between Event_scheduler and Event_queue one-way, from the former to the
latter. Event_queue now does not know about Event_scheduler.
get_state() is changed to is_running(). The state enum should be private,
as it is not needed to be seen from outside anymore.
sql/events.cc:
Event_queue does not need anymore a pointer to Event_scheduler.
Diffstat (limited to 'sql/event_scheduler.h')
-rw-r--r-- | sql/event_scheduler.h | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/sql/event_scheduler.h b/sql/event_scheduler.h index 18a805eb6f6..fc41e345dfd 100644 --- a/sql/event_scheduler.h +++ b/sql/event_scheduler.h @@ -34,14 +34,6 @@ public: Event_scheduler():state(UNINITIALIZED){} ~Event_scheduler(){} - enum enum_state - { - UNINITIALIZED = 0, - INITIALIZED, - RUNNING, - STOPPING - }; - /* State changing methods follow */ bool @@ -70,12 +62,8 @@ public: deinit_mutexes(); /* Information retrieving methods follow */ - - enum enum_state - get_state(); - - void - queue_changed(); + bool + is_running(); bool dump_internal_status(THD *thd); @@ -84,6 +72,7 @@ private: uint workers_count(); + /* helper functions */ bool execute_top(THD *thd, Event_job_data *job_data); @@ -101,16 +90,18 @@ private: pthread_mutex_t LOCK_scheduler_state; + enum enum_state + { + UNINITIALIZED = 0, + INITIALIZED, + RUNNING, + STOPPING + }; + /* 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; + THD *scheduler_thd; pthread_cond_t COND_state; |