21
21
#include <drizzled/scheduling.h>
22
22
#include <drizzled/gettext.h>
23
23
#include <drizzled/connect.h>
25
Scheduler *thread_scheduler= NULL;
24
#include "drizzled/plugin_registry.h"
27
SchedulerFactory *scheduler_factory= NULL;
27
29
static bool scheduler_inited= false; /* We must insist that only one of these plugins get loaded at a time */
30
32
extern char *opt_scheduler;
32
Scheduler &get_thread_scheduler()
34
assert(thread_scheduler != NULL);
35
return *thread_scheduler;
38
int scheduling_initializer(st_plugin_int *plugin)
40
if (memcmp(plugin->plugin->name, opt_scheduler, strlen(opt_scheduler)))
34
bool add_scheduler_factory(SchedulerFactory *factory)
36
if (factory->getName() != opt_scheduler)
43
39
if (scheduler_inited)
45
41
fprintf(stderr, "You cannot load more then one scheduler plugin\n");
44
scheduler_factory= factory;
46
scheduler_inited= true;
50
Scheduler &get_thread_scheduler()
52
assert(scheduler_factory != NULL);
53
Scheduler *sched= (*scheduler_factory)();
56
errmsg_printf(ERRMSG_LVL_ERROR, _("Scheduler initialization failed."));
62
int scheduling_initializer(st_plugin_int *plugin)
65
SchedulerFactory *factory= NULL;
49
67
assert(plugin->plugin->init); /* Find poorly designed plugins */
51
if (plugin->plugin->init((void *)&thread_scheduler))
69
if (plugin->plugin->init((void *)&factory))
54
72
TRANSLATORS> The leading word "scheduling" is the name
62
scheduler_inited= true;
80
Plugin_registry ®istry= Plugin_registry::get_plugin_registry();
82
registry.registerPlugin(factory);
63
84
/* We populate so we can find which plugin was initialized later on */
64
plugin->data= (void *)thread_scheduler;
85
plugin->data= (void *)factory;
72
93
/* We know which one we initialized since its data pointer is filled */
73
94
if (plugin->plugin->deinit && plugin->data)
75
if (plugin->plugin->deinit((void *)thread_scheduler))
96
if (plugin->plugin->deinit((void *)plugin->data))
77
98
/* TRANSLATORS: The leading word "scheduling" is the name
78
99
of the plugin api, and so should not be translated. */