~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/scheduler.cc

  • Committer: Brian Aker
  • Date: 2010-06-02 17:48:07 UTC
  • mto: (1578.6.10 explain-drizzle)
  • mto: This revision was merged to the branch mainline in revision 1589.
  • Revision ID: brian@gir-2.local-20100602174807-9unmrwp18ewkwol5
Modify merge-buffer to use std::vector in one location (just curious to see
if this shows up on benchmarks).

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