~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-02-20 22:48:37 UTC
  • Revision ID: brian@tangent.org-20090220224837-fw5wrf46n4ru3e6a
First pass of stripping uint

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright (C) 2006 MySQL AB
 
2
 
 
3
   This program is free software; you can redistribute it and/or modify
 
4
   it under the terms of the GNU General Public License as published by
 
5
   the Free Software Foundation; version 2 of the License.
 
6
 
 
7
   This program is distributed in the hope that it will be useful,
 
8
   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
   GNU General Public License for more details.
 
11
 
 
12
   You should have received a copy of the GNU General Public License
 
13
   along with this program; if not, write to the Free Software
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
15
 
 
16
#include <drizzled/server_includes.h>
 
17
#include <drizzled/gettext.h>
 
18
#include <drizzled/error.h>
 
19
#include <drizzled/plugin_scheduling.h>
 
20
#include <drizzled/serialize/serialize.h>
 
21
#include <drizzled/connect.h>
 
22
#include <drizzled/sql_parse.h>
 
23
#include <drizzled/session.h>
 
24
#include <drizzled/connect.h>
 
25
#include <string>
 
26
using namespace std;
 
27
 
 
28
static bool init_new_connection_thread(void) {return 0;}
 
29
 
 
30
/*
 
31
  Simple scheduler that use the main thread to handle the request
 
32
 
 
33
  NOTES
 
34
  This is only used for debugging, when starting mysqld with
 
35
  --thread-handling=no-threads or --one-thread
 
36
 
 
37
  When we enter this function, LOCK_thread_count is held!
 
38
*/
 
39
 
 
40
bool add_connection(Session *session)
 
41
{
 
42
  safe_mutex_assert_owner(&LOCK_thread_count);
 
43
  (void) pthread_mutex_unlock(&LOCK_thread_count);
 
44
  handle_one_connection((void*) session);
 
45
 
 
46
  return false;
 
47
}
 
48
 
 
49
 
 
50
/*
 
51
  End connection, in case when we are using 'no-threads'
 
52
*/
 
53
 
 
54
static bool end_thread(Session *session, bool)
 
55
{
 
56
  unlink_session(session);   /* locks LOCK_thread_count and deletes session */
 
57
 
 
58
  return true;                                     // Abort handle_one_connection
 
59
}
 
60
 
 
61
static int init(void *p)
 
62
{
 
63
  scheduling_st* func= (scheduling_st *)p;
 
64
 
 
65
  func->max_threads= 1;
 
66
  func->add_connection= add_connection;
 
67
  func->init_new_connection_thread= init_new_connection_thread;
 
68
  func->end_thread= end_thread;
 
69
 
 
70
  return 0;
 
71
}
 
72
 
 
73
static int deinit(void *)
 
74
{
 
75
  return 0;
 
76
}
 
77
 
 
78
static struct st_mysql_sys_var* system_variables[]= {
 
79
  NULL
 
80
};
 
81
 
 
82
drizzle_declare_plugin(single_thread)
 
83
{
 
84
  DRIZZLE_SCHEDULING_PLUGIN,
 
85
  "single_thread",
 
86
  "0.1",
 
87
  "Brian Aker",
 
88
  "Single Thread Scheduler",
 
89
  PLUGIN_LICENSE_GPL,
 
90
  init, /* Plugin Init */
 
91
  deinit, /* Plugin Deinit */
 
92
  NULL,   /* status variables */
 
93
  system_variables,   /* system variables */
 
94
  NULL    /* config options */
 
95
}
 
96
drizzle_declare_plugin_end;