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/sql_parse.h>
21
#include <drizzled/session.h>
25
using namespace drizzled;
28
* Simple scheduler that uses the main thread to handle the request. This
29
* should only be used for debugging.
31
class SingleThreadScheduler : public plugin::Scheduler
34
SingleThreadScheduler() : Scheduler() {}
36
/* When we enter this function, LOCK_thread_count is held! */
37
virtual bool addSession(Session *session)
41
session->disconnect(ER_OUT_OF_RESOURCES, true);
42
statistic_increment(aborted_connects, &LOCK_status);
47
This is not the real thread start beginning, but there is not an easy
50
session->thread_stack= (char *)&session;
53
killSessionNow(session);
57
virtual void killSessionNow(Session *session)
59
unlink_session(session);
65
class SingleThreadFactory : public plugin::SchedulerFactory
68
SingleThreadFactory() : SchedulerFactory("single_thread") {}
69
~SingleThreadFactory() { if (scheduler != NULL) delete scheduler; }
70
plugin::Scheduler *operator() ()
72
if (scheduler == NULL)
73
scheduler= new SingleThreadScheduler();
78
SingleThreadFactory *factory= NULL;
80
static int init(drizzled::plugin::Registry ®istry)
82
factory= new SingleThreadFactory();
83
registry.scheduler.add(factory);
87
static int deinit(drizzled::plugin::Registry ®istry)
91
registry.scheduler.remove(factory);
97
static struct st_mysql_sys_var* system_variables[]= {
101
drizzle_declare_plugin(single_thread)
106
"Single Thread Scheduler",
108
init, /* Plugin Init */
109
deinit, /* Plugin Deinit */
110
NULL, /* status variables */
111
system_variables, /* system variables */
112
NULL /* config options */
114
drizzle_declare_plugin_end;