19
20
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#ifndef DRIZZLED_PLUGIN_SCHEDULER_H
23
#define DRIZZLED_PLUGIN_SCHEDULER_H
25
#include "drizzled/session.h"
26
#include "drizzled/plugin/plugin.h"
23
#ifndef DRIZZLED_PLUGIN_SCHEDULING_H
24
#define DRIZZLED_PLUGIN_SCHEDULING_H
40
* This class should be used by scheduler plugins to implement custom session
43
class Scheduler : public Plugin
45
/* Disable default constructors */
47
Scheduler(const Scheduler &);
48
Scheduler& operator=(const Scheduler &);
50
explicit Scheduler(std::string name_arg)
51
: Plugin(name_arg, "Scheduler")
35
Scheduler(uint32_t threads)
36
: max_threads(threads) {}
53
38
virtual ~Scheduler() {}
56
* Add a session to the scheduler. When the scheduler is ready to run the
57
* session, it should call session->run().
59
virtual bool addSession(Session::shared_ptr &session)= 0;
62
* Notify the scheduler that it should be killed gracefully.
64
virtual void killSession(Session *) {}
67
* This is called when a scheduler should kill the session immedaitely.
69
virtual void killSessionNow(Session::shared_ptr&) {}
71
static bool addPlugin(plugin::Scheduler *sced);
72
static void removePlugin(plugin::Scheduler *sced);
73
static bool setPlugin(const std::string& name);
74
static Scheduler *getScheduler();
77
} /* namespace plugin */
78
} /* namespace drizzled */
80
#endif /* DRIZZLED_PLUGIN_SCHEDULER_H */
40
uint32_t get_max_threads()
45
virtual uint32_t count(void)= 0;
46
virtual bool add_connection(Session *session)= 0;
48
virtual bool end_thread(Session *, bool) {return false;}
49
virtual bool init_new_connection_thread(void)
56
virtual void post_kill_notification(Session *) {}
59
class SchedulerFactory
62
std::vector<std::string> aliases;
66
SchedulerFactory(std::string name_arg): name(name_arg), scheduler(NULL) {}
67
SchedulerFactory(const char *name_arg): name(name_arg), scheduler(NULL) {}
68
virtual ~SchedulerFactory() {}
69
virtual Scheduler *operator()(void)= 0;
70
std::string getName() {return name;}
71
const std::vector<std::string>& getAliases() {return aliases;}
72
void addAlias(std::string alias)
74
aliases.push_back(alias);
79
#endif /* DRIZZLED_PLUGIN_SCHEDULING_H */