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
|
|
|
|
|
|
|
/*
|
|
|
|
Threadpool statistics
|
|
|
|
*/
|
|
|
|
struct TP_STATISTICS
|
|
|
|
{
|
|
|
|
/* Current number of worker thread. */
|
|
|
|
volatile int num_worker_threads;
|
|
|
|
/* Current number of idle threads. */
|
|
|
|
volatile int num_waiting_threads;
|
|
|
|
/* Number of login requests are queued but not yet processed. */
|
|
|
|
volatile int pending_login_requests;
|
|
|
|
/* Number of threads that are starting. */
|
|
|
|
volatile int pending_thread_starts;
|
|
|
|
/* Number of threads that are being shut down */
|
|
|
|
volatile int pending_thread_shutdowns;
|
|
|
|
/* Time (in milliseconds) since pool is blocked (num_waiting_threads is 0) */
|
|
|
|
ulonglong pool_block_duration;
|
|
|
|
/* Maximum duration of the pending login, im milliseconds. */
|
|
|
|
ulonglong pending_login_duration;
|
|
|
|
/* Time since last thread was created */
|
|
|
|
ulonglong time_since_last_thread_creation;
|
|
|
|
/* Number of requests processed since pool monitor run last time. */
|
|
|
|
volatile int requests_dequeued;
|
|
|
|
volatile int requests_completed;
|
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
|