~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/scheduler.cc

  • Committer: Stewart Smith
  • Date: 2010-11-07 04:22:31 UTC
  • mto: (1911.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1912.
  • Revision ID: stewart@flamingspork.com-20101107042231-ola4sl7j0qvg58tz
fix ARCHIVE storage engine calling exit (lintian warning). Was because we were linking in libinternal into libazio, which links into archive plugin. Just link libinternal into the command line utilities.

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