1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
#include "drizzled/plugin/scheduler.h"
26
#include "drizzled/gettext.h"
27
#include "drizzled/errmsg_print.h"
34
extern size_t my_thread_stack_size;
36
vector<plugin::Scheduler *> all_schedulers;
39
static plugin::Scheduler *scheduler= NULL;
42
class FindSchedulerByName : public unary_function<plugin::Scheduler *, bool>
46
FindSchedulerByName(const string *name_arg)
48
result_type operator() (argument_type sched)
50
return (bool)((name->compare(sched->getName()) == 0));
55
bool plugin::Scheduler::addPlugin(plugin::Scheduler *sched)
57
vector<plugin::Scheduler *>::iterator iter=
58
find_if(all_schedulers.begin(), all_schedulers.end(),
59
FindSchedulerByName(&sched->getName()));
61
if (iter != all_schedulers.end())
63
errmsg_printf(ERRMSG_LVL_ERROR,
64
_("Attempted to register a scheduler %s, but a scheduler "
65
"has already been registered with that name.\n"),
66
sched->getName().c_str());
71
all_schedulers.push_back(sched);
77
void plugin::Scheduler::removePlugin(plugin::Scheduler *sched)
79
all_schedulers.erase(find(all_schedulers.begin(),
85
bool plugin::Scheduler::setPlugin(const string& name)
87
vector<plugin::Scheduler *>::iterator iter=
88
find_if(all_schedulers.begin(), all_schedulers.end(),
89
FindSchedulerByName(&name));
91
if (iter != all_schedulers.end())
93
if (scheduler != NULL)
94
scheduler->deactivate();
96
scheduler->activate();
100
errmsg_printf(ERRMSG_LVL_WARN,
101
_("Attempted to configure %s as the scheduler, which did "
102
"not exist.\n"), name.c_str());
107
plugin::Scheduler *plugin::Scheduler::getScheduler()
112
} /* namespace drizzled */