~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/multi_thread/multi_thread.cc

  • Committer: Brian Aker
  • Date: 2010-11-11 04:18:45 UTC
  • mfrom: (1897.4.20 rip-plugin-sysvar)
  • Revision ID: brian@tangent.org-20101111041845-b7td4vnx4wu01ga1
Merge in changes from Monty for sys var.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
using namespace drizzled;
29
29
 
30
30
/* Configuration variables. */
31
 
static uint32_t max_threads;
32
 
 
33
 
/* Global's (TBR) */
34
 
static MultiThreadScheduler *scheduler= NULL;
 
31
typedef constrained_check<uint32_t, 4096, 1> max_threads_constraint;
 
32
static max_threads_constraint max_threads;
35
33
 
36
34
namespace drizzled
37
35
{
130
128
static int init(drizzled::module::Context &context)
131
129
{
132
130
  
133
 
  const module::option_map &vm= context.getOptions();
134
 
  if (vm.count("max-threads"))
135
 
  {
136
 
    if (max_threads > 4096 || max_threads < 1)
137
 
    {
138
 
      errmsg_printf(ERRMSG_LVL_ERROR, _("Invalid value for max-threads\n"));
139
 
      return 1;
140
 
    }
141
 
  }
142
 
 
143
 
  scheduler= new MultiThreadScheduler("multi_thread");
144
 
  context.add(scheduler);
 
131
  context.add(new MultiThreadScheduler("multi_thread"));
145
132
 
146
133
  return 0;
147
134
}
148
135
 
149
 
static DRIZZLE_SYSVAR_UINT(max_threads, max_threads,
150
 
                           PLUGIN_VAR_RQCMDARG,
151
 
                           N_("Maximum number of user threads available."),
152
 
                           NULL, NULL, 2048, 1, 4096, 0);
153
 
 
154
136
static void init_options(drizzled::module::option_context &context)
155
137
{
156
138
  context("max-threads",
157
 
          po::value<uint32_t>(&max_threads)->default_value(2048),
 
139
          po::value<max_threads_constraint>(&max_threads)->default_value(2048),
158
140
          N_("Maximum number of user threads available."));
159
141
}
160
142
 
161
 
static drizzle_sys_var* sys_variables[]= {
162
 
  DRIZZLE_SYSVAR(max_threads),
163
 
  NULL
164
 
};
165
 
 
166
143
DRIZZLE_DECLARE_PLUGIN
167
144
{
168
145
  DRIZZLE_VERSION_ID,
172
149
  "One Thread Per Session Scheduler",
173
150
  PLUGIN_LICENSE_GPL,
174
151
  init, /* Plugin Init */
175
 
  sys_variables,   /* system variables */
 
152
  NULL,   /* system variables */
176
153
  init_options    /* config options */
177
154
}
178
155
DRIZZLE_DECLARE_PLUGIN_END;