1
/* Copyright (C) 2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
16
#include <drizzled/server_includes.h>
17
#include <drizzled/gettext.h>
18
#include <drizzled/error.h>
19
#include <drizzled/plugin/scheduler.h>
20
#include <drizzled/connect.h>
21
#include <drizzled/sql_parse.h>
22
#include <drizzled/session.h>
23
#include <drizzled/connect.h>
27
class Single_thread_scheduler : public Scheduler
30
Single_thread_scheduler()
33
virtual bool init_new_connection_thread(void) {return 0;}
36
Simple scheduler that use the main thread to handle the request
39
This is only used for debugging, when starting mysqld with
40
--thread-handling=no-threads or --one-thread
42
When we enter this function, LOCK_thread_count is held!
45
virtual bool add_connection(Session *session)
47
handle_one_connection((void*) session);
54
End connection, in case when we are using 'no-threads'
57
virtual bool end_thread(Session *session, bool)
59
unlink_session(session); /* locks LOCK_thread_count and deletes session */
61
return true; // Abort handle_one_connection
65
virtual uint32_t count(void)
73
class SingleThreadFactory : public SchedulerFactory
76
SingleThreadFactory() : SchedulerFactory("single_thread") {}
77
~SingleThreadFactory() { if (scheduler != NULL) delete scheduler; }
78
Scheduler *operator() ()
80
if (scheduler == NULL)
81
scheduler= new Single_thread_scheduler();
86
SingleThreadFactory *factory= NULL;
88
static int init(PluginRegistry ®istry)
90
factory= new SingleThreadFactory();
91
registry.add(factory);
95
static int deinit(PluginRegistry ®istry)
99
registry.remove(factory);
105
static struct st_mysql_sys_var* system_variables[]= {
109
drizzle_declare_plugin(single_thread)
114
"Single Thread Scheduler",
116
init, /* Plugin Init */
117
deinit, /* Plugin Deinit */
118
NULL, /* status variables */
119
system_variables, /* system variables */
120
NULL /* config options */
122
drizzle_declare_plugin_end;