summaryrefslogtreecommitdiffstats
path: root/misc/thread_pool.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2018-05-06 16:17:47 +0200
committerwm4 <wm4@nowhere>2018-05-24 19:56:34 +0200
commita1ed1f8be09c927994b58399e77e99336ec7f436 (patch)
tree8989650d9c899dcd140223e10f15a756ad9f0c7f /misc/thread_pool.h
parenta0308d31697c5dd601ee036acbc937c361746cc3 (diff)
downloadmpv-a1ed1f8be09c927994b58399e77e99336ec7f436.tar.bz2
mpv-a1ed1f8be09c927994b58399e77e99336ec7f436.tar.xz
thread_pool: make it slightly less dumb
The existing thread pool code is the most primitive thread pool possible. That's fine, but one annoying thing was that it used a static number of threads. Make it dynamic, so we don't need to "waste" idle threads. This tries to add threads as needed. If threads are idle for some time, destroy them again until a minimum number of threads is reached. Also change the license to ISC.
Diffstat (limited to 'misc/thread_pool.h')
-rw-r--r--misc/thread_pool.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/misc/thread_pool.h b/misc/thread_pool.h
index c7af7b2b57..7d5aed0531 100644
--- a/misc/thread_pool.h
+++ b/misc/thread_pool.h
@@ -3,8 +3,10 @@
struct mp_thread_pool;
-struct mp_thread_pool *mp_thread_pool_create(void *ta_parent, int threads);
-void mp_thread_pool_queue(struct mp_thread_pool *pool, void (*fn)(void *ctx),
+struct mp_thread_pool *mp_thread_pool_create(void *ta_parent, int init_threads,
+ int min_threads, int max_threads);
+
+bool mp_thread_pool_queue(struct mp_thread_pool *pool, void (*fn)(void *ctx),
void *fn_ctx);
#endif