diff options
author | Yann Ylavic <ylavic@apache.org> | 2022-07-14 10:31:22 +0000 |
---|---|---|
committer | Yann Ylavic <ylavic@apache.org> | 2022-07-14 10:31:22 +0000 |
commit | ab59882d46f992fe13e696e0275a244123d51349 (patch) | |
tree | bc3ca68e32583a248001d06e307eb22b5a53a744 /include | |
parent | 4bcb664471a5e05a290dc57bb67fa22d3323b207 (diff) | |
download | apr-ab59882d46f992fe13e696e0275a244123d51349.tar.gz |
apr_thread: Provide apr_threadattr_max_free_set().
When creating a thread, this allows to specify the "max_free" of its pool
allocator (i.e. apr_allocator_max_free_set), so that one can create thread
local subpools and have their memory usage regulated on cleanup/destroy.
One could achieve that already with:
apr_allocator_max_free_set(apr_thread_pool_get(thread), max_free);
in the thread startup function, but it's more convenient, simpler and race
free to handle that in the thread attribute itself at creation time.
git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1902715 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include')
-rw-r--r-- | include/apr_thread_proc.h | 9 | ||||
-rw-r--r-- | include/arch/beos/apr_arch_threadproc.h | 1 | ||||
-rw-r--r-- | include/arch/netware/apr_arch_threadproc.h | 1 | ||||
-rw-r--r-- | include/arch/os2/apr_arch_threadproc.h | 1 | ||||
-rw-r--r-- | include/arch/unix/apr_arch_threadproc.h | 1 | ||||
-rw-r--r-- | include/arch/win32/apr_arch_threadproc.h | 1 |
6 files changed, 14 insertions, 0 deletions
diff --git a/include/apr_thread_proc.h b/include/apr_thread_proc.h index 952c76d2d..07571b6a1 100644 --- a/include/apr_thread_proc.h +++ b/include/apr_thread_proc.h @@ -278,6 +278,15 @@ APR_DECLARE(apr_status_t) apr_threadattr_guardsize_set(apr_threadattr_t *attr, apr_size_t guardsize); /** + * Set the threshold at which the thread pool allocator should start + * giving blocks back to the system. + * @param attr The threadattr to affect + * @param on Non-zero if detached threads should be created. + */ +APR_DECLARE(apr_status_t) apr_threadattr_max_free_set(apr_threadattr_t *attr, + apr_size_t size); + +/** * Create a new thread of execution * @param new_thread The newly created thread handle. * @param attr The threadattr to use to determine how to create the thread diff --git a/include/arch/beos/apr_arch_threadproc.h b/include/arch/beos/apr_arch_threadproc.h index 6754681c8..5c67c879e 100644 --- a/include/arch/beos/apr_arch_threadproc.h +++ b/include/arch/beos/apr_arch_threadproc.h @@ -53,6 +53,7 @@ struct apr_threadattr_t { int32 attr; int detached; int joinable; + apr_size_t max_free; }; struct apr_threadkey_t { diff --git a/include/arch/netware/apr_arch_threadproc.h b/include/arch/netware/apr_arch_threadproc.h index ce217aaba..d726b34f7 100644 --- a/include/arch/netware/apr_arch_threadproc.h +++ b/include/arch/netware/apr_arch_threadproc.h @@ -44,6 +44,7 @@ struct apr_threadattr_t { apr_size_t stack_size; apr_int32_t detach; char *thread_name; + apr_size_t max_free; }; struct apr_threadkey_t { diff --git a/include/arch/os2/apr_arch_threadproc.h b/include/arch/os2/apr_arch_threadproc.h index c8017adbf..5e6b6a40d 100644 --- a/include/arch/os2/apr_arch_threadproc.h +++ b/include/arch/os2/apr_arch_threadproc.h @@ -29,6 +29,7 @@ struct apr_threadattr_t { apr_pool_t *pool; unsigned long attr; apr_size_t stacksize; + apr_size_t max_free; }; struct apr_thread_t { diff --git a/include/arch/unix/apr_arch_threadproc.h b/include/arch/unix/apr_arch_threadproc.h index adeb51c8a..c39aeaa8f 100644 --- a/include/arch/unix/apr_arch_threadproc.h +++ b/include/arch/unix/apr_arch_threadproc.h @@ -65,6 +65,7 @@ struct apr_thread_t { struct apr_threadattr_t { apr_pool_t *pool; pthread_attr_t attr; + apr_size_t max_free; }; struct apr_threadkey_t { diff --git a/include/arch/win32/apr_arch_threadproc.h b/include/arch/win32/apr_arch_threadproc.h index 13568256e..23b0172ec 100644 --- a/include/arch/win32/apr_arch_threadproc.h +++ b/include/arch/win32/apr_arch_threadproc.h @@ -38,6 +38,7 @@ struct apr_threadattr_t { apr_pool_t *pool; apr_int32_t detach; apr_size_t stacksize; + apr_size_t max_free; }; struct apr_threadkey_t { |