2011-12-08 19:17:49 +01:00
|
|
|
|
2011-12-19 13:28:30 +01:00
|
|
|
#define MAX_THREAD_GROUPS 128
|
|
|
|
|
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 */
|
|
|
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
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);
|
|
|
|
|
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
|
|
|
/* Current number of idle threads. */
|
2012-01-15 11:17:45 +01:00
|
|
|
volatile int32 num_waiting_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);
|
2011-12-19 13:28:30 +01:00
|
|
|
extern int 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);
|
|
|
|
|