17
17
#include <drizzled/gettext.h>
18
18
#include <drizzled/error.h>
19
19
#include <drizzled/plugin/scheduler.h>
20
#include <drizzled/connect.h>
21
20
#include <drizzled/sql_parse.h>
22
21
#include <drizzled/session.h>
23
#include <drizzled/connect.h>
25
24
using namespace std;
25
using namespace drizzled;
27
class Single_thread_scheduler : public Scheduler
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
30
Single_thread_scheduler()
34
SingleThreadScheduler() : 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)
36
/* When we enter this function, LOCK_thread_count is held! */
37
virtual bool addSession(Session *session)
47
handle_one_connection((void*) 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);
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)
57
virtual void killSessionNow(Session *session)
59
unlink_session(session);
73
class SingleThreadFactory : public SchedulerFactory
65
class SingleThreadFactory : public plugin::SchedulerFactory
76
68
SingleThreadFactory() : SchedulerFactory("single_thread") {}
77
69
~SingleThreadFactory() { if (scheduler != NULL) delete scheduler; }
78
Scheduler *operator() ()
70
plugin::Scheduler *operator() ()
80
72
if (scheduler == NULL)
81
scheduler= new Single_thread_scheduler();
73
scheduler= new SingleThreadScheduler();