13
13
along with this program; if not, write to the Free Software
14
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>
16
#include <plugin/single_thread/single_thread.h>
24
18
using namespace std;
25
19
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;
23
static SingleThreadScheduler *scheduler= NULL;
80
26
static int init(drizzled::plugin::Registry ®istry)
82
factory= new SingleThreadFactory();
83
registry.add(factory);
28
scheduler= new SingleThreadScheduler("single_thread");
29
registry.add(scheduler);
87
33
static int deinit(drizzled::plugin::Registry ®istry)
91
registry.remove(factory);
35
registry.remove(scheduler);