~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/scheduler.cc

  • Committer: Brian Aker
  • Date: 2009-12-06 01:55:53 UTC
  • mfrom: (1238.1.5 push)
  • Revision ID: brian@gaz-20091206015553-cva833q4gvwj11ob
Bundle for staging.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include <config.h>
21
 
 
22
 
#include <algorithm>
23
 
 
24
 
#include <drizzled/errmsg_print.h>
25
 
#include <drizzled/gettext.h>
26
 
#include <drizzled/plugin/scheduler.h>
 
20
#include "drizzled/server_includes.h"
 
21
#include "drizzled/plugin/scheduler.h"
 
22
#include "drizzled/plugin/registry.h"
 
23
 
 
24
#include "drizzled/gettext.h"
 
25
 
 
26
using namespace std;
27
27
 
28
28
namespace drizzled
29
29
{
30
30
 
31
 
extern size_t my_thread_stack_size;
32
 
 
33
 
std::vector<plugin::Scheduler *> all_schedulers;
 
31
vector<plugin::Scheduler *> all_schedulers;
34
32
 
35
33
/* Globals (TBK) */
36
34
static plugin::Scheduler *scheduler= NULL;
37
35
 
38
36
 
39
 
class FindSchedulerByName : public std::unary_function<plugin::Scheduler *, bool>
 
37
class FindSchedulerByName : public unary_function<plugin::Scheduler *, bool>
40
38
{
41
 
  const std::string *name;
 
39
  const string *name;
42
40
public:
43
 
  FindSchedulerByName(const std::string *name_arg)
 
41
  FindSchedulerByName(const string *name_arg)
44
42
    : name(name_arg) {}
45
43
  result_type operator() (argument_type sched)
46
44
  {
51
49
 
52
50
bool plugin::Scheduler::addPlugin(plugin::Scheduler *sched)
53
51
{
54
 
  std::vector<plugin::Scheduler *>::iterator iter=
55
 
    std::find_if(all_schedulers.begin(), all_schedulers.end(), 
 
52
  vector<plugin::Scheduler *>::iterator iter=
 
53
    find_if(all_schedulers.begin(), all_schedulers.end(), 
56
54
            FindSchedulerByName(&sched->getName()));
57
55
 
58
56
  if (iter != all_schedulers.end())
59
57
  {
60
 
    errmsg_printf(error::ERROR,
 
58
    errmsg_printf(ERRMSG_LVL_ERROR,
61
59
                  _("Attempted to register a scheduler %s, but a scheduler "
62
60
                    "has already been registered with that name.\n"),
63
61
                    sched->getName().c_str());
73
71
 
74
72
void plugin::Scheduler::removePlugin(plugin::Scheduler *sched)
75
73
{
76
 
  all_schedulers.erase(std::find(all_schedulers.begin(),
 
74
  all_schedulers.erase(find(all_schedulers.begin(),
77
75
                            all_schedulers.end(),
78
76
                            sched));
79
77
}
80
78
 
81
79
 
82
 
bool plugin::Scheduler::setPlugin(const std::string& name)
 
80
bool plugin::Scheduler::setPlugin(const string& name)
83
81
{
84
 
  std::vector<plugin::Scheduler *>::iterator iter=
85
 
    std::find_if(all_schedulers.begin(), all_schedulers.end(), 
 
82
  vector<plugin::Scheduler *>::iterator iter=
 
83
    find_if(all_schedulers.begin(), all_schedulers.end(), 
86
84
            FindSchedulerByName(&name));
87
85
 
88
86
  if (iter != all_schedulers.end())
94
92
    return false;
95
93
  }
96
94
 
97
 
  errmsg_printf(error::WARN,
 
95
  errmsg_printf(ERRMSG_LVL_WARN,
98
96
                _("Attempted to configure %s as the scheduler, which did "
99
97
                  "not exist.\n"), name.c_str());
100
98
  return true;