summaryrefslogtreecommitdiff
path: root/sql/threadpool.h
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@montyprogram.com>2011-12-08 19:17:49 +0100
committerVladislav Vaintroub <wlad@montyprogram.com>2011-12-08 19:17:49 +0100
commite91bbca5fb080a8d988c156d78c7dc1b1daaad82 (patch)
treeedeb15da451e956ae0d6874657c910ab0df111f8 /sql/threadpool.h
parent5e7b949e61f4330e27013c8ec81fa3d450e5dce6 (diff)
downloadmariadb-git-e91bbca5fb080a8d988c156d78c7dc1b1daaad82.tar.gz
Initial threadpool implementation for MariaDB 5.5
Diffstat (limited to 'sql/threadpool.h')
-rw-r--r--sql/threadpool.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/sql/threadpool.h b/sql/threadpool.h
new file mode 100644
index 00000000000..0694981d76f
--- /dev/null
+++ b/sql/threadpool.h
@@ -0,0 +1,47 @@
+
+/* Threadpool parameters */
+#ifdef _WIN32
+extern uint threadpool_min_threads; /* Minimum threads in pool */
+#else
+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*/
+#endif
+extern uint threadpool_max_threads; /* Maximum threads in pool */
+
+/*
+ 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);
+
+/* Activate threadpool scheduler */
+extern void tp_scheduler(void);
+