~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/scheduler.cc

Updated pandora-build files to version 0.133

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
26
26
#include "drizzled/gettext.h"
27
27
#include "drizzled/errmsg_print.h"
28
28
 
 
29
using namespace std;
 
30
 
29
31
namespace drizzled
30
32
{
31
33
 
32
 
extern size_t my_thread_stack_size;
33
 
 
34
 
std::vector<plugin::Scheduler *> all_schedulers;
 
34
vector<plugin::Scheduler *> all_schedulers;
35
35
 
36
36
/* Globals (TBK) */
37
37
static plugin::Scheduler *scheduler= NULL;
38
38
 
39
39
 
40
 
class FindSchedulerByName : public std::unary_function<plugin::Scheduler *, bool>
 
40
class FindSchedulerByName : public unary_function<plugin::Scheduler *, bool>
41
41
{
42
 
  const std::string *name;
 
42
  const string *name;
43
43
public:
44
 
  FindSchedulerByName(const std::string *name_arg)
 
44
  FindSchedulerByName(const string *name_arg)
45
45
    : name(name_arg) {}
46
46
  result_type operator() (argument_type sched)
47
47
  {
52
52
 
53
53
bool plugin::Scheduler::addPlugin(plugin::Scheduler *sched)
54
54
{
55
 
  std::vector<plugin::Scheduler *>::iterator iter=
56
 
    std::find_if(all_schedulers.begin(), all_schedulers.end(), 
 
55
  vector<plugin::Scheduler *>::iterator iter=
 
56
    find_if(all_schedulers.begin(), all_schedulers.end(), 
57
57
            FindSchedulerByName(&sched->getName()));
58
58
 
59
59
  if (iter != all_schedulers.end())
60
60
  {
61
 
    errmsg_printf(error::ERROR,
 
61
    errmsg_printf(ERRMSG_LVL_ERROR,
62
62
                  _("Attempted to register a scheduler %s, but a scheduler "
63
63
                    "has already been registered with that name.\n"),
64
64
                    sched->getName().c_str());
74
74
 
75
75
void plugin::Scheduler::removePlugin(plugin::Scheduler *sched)
76
76
{
77
 
  all_schedulers.erase(std::find(all_schedulers.begin(),
 
77
  all_schedulers.erase(find(all_schedulers.begin(),
78
78
                            all_schedulers.end(),
79
79
                            sched));
80
80
}
81
81
 
82
82
 
83
 
bool plugin::Scheduler::setPlugin(const std::string& name)
 
83
bool plugin::Scheduler::setPlugin(const string& name)
84
84
{
85
 
  std::vector<plugin::Scheduler *>::iterator iter=
86
 
    std::find_if(all_schedulers.begin(), all_schedulers.end(), 
 
85
  vector<plugin::Scheduler *>::iterator iter=
 
86
    find_if(all_schedulers.begin(), all_schedulers.end(), 
87
87
            FindSchedulerByName(&name));
88
88
 
89
89
  if (iter != all_schedulers.end())
95
95
    return false;
96
96
  }
97
97
 
98
 
  errmsg_printf(error::WARN,
 
98
  errmsg_printf(ERRMSG_LVL_WARN,
99
99
                _("Attempted to configure %s as the scheduler, which did "
100
100
                  "not exist.\n"), name.c_str());
101
101
  return true;