~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/plugin/scheduler.h

  • Committer: Brian Aker
  • Date: 2009-05-11 17:50:22 UTC
  • Revision ID: brian@gaz-20090511175022-y35q9ky6uh9ldcjt
Replacing Sun employee copyright headers (aka... anything done by a Sun
employee is copyright by Sun).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
3
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
4
 
 
5
 *  Definitions required for Configuration Variables plugin
 
6
 
 
7
 *  Copyright (C) 2008 Sun Microsystems
 
8
 *
 
9
 *  This program is free software; you can redistribute it and/or modify
 
10
 *  it under the terms of the GNU General Public License as published by
 
11
 *  the Free Software Foundation; version 2 of the License.
 
12
 *
 
13
 *  This program is distributed in the hope that it will be useful,
 
14
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
15
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
16
 *  GNU General Public License for more details.
 
17
 *
 
18
 *  You should have received a copy of the GNU General Public License
 
19
 *  along with this program; if not, write to the Free Software
 
20
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
21
 */
 
22
 
 
23
#ifndef DRIZZLED_PLUGIN_SCHEDULING_H
 
24
#define DRIZZLED_PLUGIN_SCHEDULING_H
 
25
 
 
26
#include <string>
 
27
#include <vector>
 
28
 
 
29
class Scheduler
 
30
{
 
31
private:
 
32
  uint32_t max_threads;
 
33
public:
 
34
 
 
35
  Scheduler(uint32_t threads)
 
36
    : max_threads(threads) {}
 
37
 
 
38
  virtual ~Scheduler() {}
 
39
 
 
40
  uint32_t get_max_threads()
 
41
  {
 
42
    return max_threads;
 
43
  }
 
44
 
 
45
  virtual uint32_t count(void)= 0;
 
46
  virtual bool add_connection(Session *session)= 0;
 
47
 
 
48
  virtual bool end_thread(Session *, bool) {return false;}
 
49
  virtual bool init_new_connection_thread(void)
 
50
  {
 
51
    if (my_thread_init())
 
52
      return true;
 
53
    return false;
 
54
  }
 
55
 
 
56
  virtual void post_kill_notification(Session *) {}
 
57
};
 
58
 
 
59
class SchedulerFactory
 
60
{
 
61
  std::string name;
 
62
  std::vector<std::string> aliases;
 
63
protected:
 
64
  Scheduler *scheduler;
 
65
public:
 
66
  SchedulerFactory(std::string name_arg): name(name_arg), scheduler(NULL) {}
 
67
  SchedulerFactory(const char *name_arg): name(name_arg), scheduler(NULL) {}
 
68
  virtual ~SchedulerFactory() {}
 
69
  virtual Scheduler *operator()(void)= 0;
 
70
  std::string getName() {return name;}
 
71
  const std::vector<std::string>& getAliases() {return aliases;}
 
72
  void addAlias(std::string alias)
 
73
  {
 
74
    aliases.push_back(alias);
 
75
  }
 
76
 
 
77
};
 
78
 
 
79
#endif /* DRIZZLED_PLUGIN_SCHEDULING_H */