2012-02-17 23:27:15 +01:00
|
|
|
/* Copyright (C) 2012 Monty Program Ab
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
2011-12-08 19:17:49 +01:00
|
|
|
|
2013-11-05 06:18:59 +01:00
|
|
|
#define MAX_THREAD_GROUPS 100000
|
2011-12-19 13:28:30 +01:00
|
|
|
|
2011-12-08 19:17:49 +01:00
|
|
|
/* Threadpool parameters */
|
|
|
|
extern uint threadpool_min_threads; /* Minimum threads in pool */
|
|
|
|
extern uint threadpool_idle_timeout; /* Shutdown idle worker threads after this timeout */
|
|
|
|
extern uint threadpool_size; /* Number of parallel executing threads */
|
2013-11-05 06:18:59 +01:00
|
|
|
extern uint threadpool_max_size;
|
2011-12-08 19:17:49 +01:00
|
|
|
extern uint threadpool_stall_limit; /* time interval in 10 ms units for stall checks*/
|
|
|
|
extern uint threadpool_max_threads; /* Maximum threads in pool */
|
2011-12-31 05:24:11 +01:00
|
|
|
extern uint threadpool_oversubscribe; /* Maximum active threads in group */
|
2011-12-08 19:17:49 +01:00
|
|
|
|
2012-01-15 11:17:45 +01:00
|
|
|
|
2012-01-24 03:23:14 +01:00
|
|
|
|
|
|
|
/* Common thread pool routines, suitable for different implementations */
|
|
|
|
extern void threadpool_remove_connection(THD *thd);
|
|
|
|
extern int threadpool_process_request(THD *thd);
|
|
|
|
extern int threadpool_add_connection(THD *thd);
|
|
|
|
|
2012-01-15 11:17:45 +01:00
|
|
|
/*
|
|
|
|
Functions used by scheduler.
|
|
|
|
OS-specific implementations are in
|
|
|
|
threadpool_unix.cc or threadpool_win.cc
|
|
|
|
*/
|
|
|
|
extern bool tp_init();
|
|
|
|
extern void tp_add_connection(THD*);
|
|
|
|
extern void tp_wait_begin(THD *, int);
|
|
|
|
extern void tp_wait_end(THD*);
|
|
|
|
extern void tp_post_kill_notification(THD *thd);
|
|
|
|
extern void tp_end(void);
|
|
|
|
|
2012-01-15 15:41:25 +01:00
|
|
|
/* Used in SHOW for threadpool_idle_thread_count */
|
|
|
|
extern int tp_get_idle_thread_count();
|
|
|
|
|
2011-12-08 19:17:49 +01:00
|
|
|
/*
|
|
|
|
Threadpool statistics
|
|
|
|
*/
|
|
|
|
struct TP_STATISTICS
|
|
|
|
{
|
|
|
|
/* Current number of worker thread. */
|
2012-01-15 11:17:45 +01:00
|
|
|
volatile int32 num_worker_threads;
|
2011-12-08 19:17:49 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern TP_STATISTICS tp_stats;
|
|
|
|
|
|
|
|
|
|
|
|
/* Functions to set threadpool parameters */
|
|
|
|
extern void tp_set_min_threads(uint val);
|
|
|
|
extern void tp_set_max_threads(uint val);
|
2012-02-16 16:59:04 +01:00
|
|
|
extern void tp_set_threadpool_size(uint val);
|
2011-12-29 21:11:06 +01:00
|
|
|
extern void tp_set_threadpool_stall_limit(uint val);
|
2011-12-08 19:17:49 +01:00
|
|
|
|
|
|
|
/* Activate threadpool scheduler */
|
|
|
|
extern void tp_scheduler(void);
|
|
|
|
|
2012-01-15 15:41:25 +01:00
|
|
|
extern int show_threadpool_idle_threads(THD *thd, SHOW_VAR *var, char *buff);
|