~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/single_thread/single_thread.cc

  • Committer: Brian Aker
  • Date: 2009-04-13 16:22:40 UTC
  • mfrom: (971.1.78 mordred)
  • Revision ID: brian@gaz-20090413162240-ugi3gvhofmcuglzl
Merge Monty

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include <drizzled/gettext.h>
18
18
#include <drizzled/error.h>
19
19
#include <drizzled/plugin/scheduler.h>
20
 
#include <drizzled/serialize/serialize.h>
21
20
#include <drizzled/connect.h>
22
21
#include <drizzled/sql_parse.h>
23
22
#include <drizzled/session.h>
28
27
class Single_thread_scheduler : public Scheduler
29
28
{
30
29
public:
31
 
  Single_thread_scheduler(uint32_t threads): Scheduler(threads) {}
 
30
  Single_thread_scheduler()
 
31
    : Scheduler(1) {}
32
32
 
33
33
  virtual bool init_new_connection_thread(void) {return 0;}
34
34
  
69
69
  
70
70
};
71
71
 
72
 
static int init(void *p)
73
 
{
74
 
  Scheduler **sched= static_cast<Scheduler **>(p);
75
 
  *sched= new Single_thread_scheduler(1);
76
 
 
 
72
 
 
73
class SingleThreadFactory : public SchedulerFactory
 
74
{
 
75
public:
 
76
  SingleThreadFactory() : SchedulerFactory("single_thread") {}
 
77
  ~SingleThreadFactory() { if (scheduler != NULL) delete scheduler; }
 
78
  Scheduler *operator() ()
 
79
  {
 
80
    if (scheduler == NULL)
 
81
      scheduler= new Single_thread_scheduler();
 
82
    return scheduler;
 
83
  }
 
84
};
 
85
 
 
86
SingleThreadFactory *factory= NULL;
 
87
 
 
88
static int init(PluginRegistry &registry)
 
89
{
 
90
  factory= new SingleThreadFactory();
 
91
  registry.add(factory);
77
92
  return 0;
78
93
}
79
94
 
80
 
static int deinit(void *p)
 
95
static int deinit(PluginRegistry &registry)
81
96
{
82
 
  Scheduler *sched= static_cast<Scheduler *>(p);
83
 
  delete sched;
 
97
  if (factory)
 
98
  {
 
99
    registry.remove(factory);
 
100
    delete factory;
 
101
  }
84
102
  return 0;
85
103
}
86
104
 
90
108
 
91
109
drizzle_declare_plugin(single_thread)
92
110
{
93
 
  DRIZZLE_SCHEDULING_PLUGIN,
94
111
  "single_thread",
95
112
  "0.1",
96
113
  "Brian Aker",