~drizzle-trunk/drizzle/development

1 by brian
clean slate
1
/* Copyright (C) 2007 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
16
/*
17
  Classes for the thread scheduler
18
*/
19
20
#ifdef USE_PRAGMA_INTERFACE
21
#pragma interface
22
#endif
23
24
class THD;
25
26
/* Functions used when manipulating threads */
27
28
class scheduler_functions
29
{
30
public:
31
  uint max_threads;
32
  bool (*init)(void);
33
  bool (*init_new_connection_thread)(void);
34
  void (*add_connection)(THD *thd);
35
  void (*post_kill_notification)(THD *thd);
36
  bool (*end_thread)(THD *thd, bool cache_thread);
37
  void (*end)(void);
38
  scheduler_functions();
39
};
40
41
enum scheduler_types
42
{
43
  SCHEDULER_ONE_THREAD_PER_CONNECTION=0,
44
  SCHEDULER_NO_THREADS,
45
  SCHEDULER_POOL_OF_THREADS
46
};
47
48
void one_thread_per_connection_scheduler(scheduler_functions* func);
49
void one_thread_scheduler(scheduler_functions* func);
50
51
#define HAVE_POOL_OF_THREADS 1
52
53
struct event;
54
55
class thd_scheduler
56
{
57
public:
58
  bool logged_in;
59
  struct event* io_event;
60
  LIST list;
61
  bool thread_attached;  /* Indicates if THD is attached to the OS thread */
62
  
63
#ifndef DBUG_OFF
64
  char dbug_explain_buf[256];
65
  void swap_dbug_explain();
66
#endif
67
68
  thd_scheduler();
69
  ~thd_scheduler();
70
  bool init(THD* parent_thd);
71
  bool thread_attach();
72
  void thread_detach();
73
};
74
75
void pool_of_threads_scheduler(scheduler_functions* func);