Apache2
apr_thread_pool.h File Reference

APR Thread Pool Library. More...

#include "apu.h"
#include "apr_thread_proc.h"
Include dependency graph for apr_thread_pool.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define APR_THREAD_TASK_PRIORITY_LOWEST   0
 
#define APR_THREAD_TASK_PRIORITY_LOW   63
 
#define APR_THREAD_TASK_PRIORITY_NORMAL   127
 
#define APR_THREAD_TASK_PRIORITY_HIGH   191
 
#define APR_THREAD_TASK_PRIORITY_HIGHEST   255
 

Typedefs

typedef struct apr_thread_pool apr_thread_pool_t
 

Functions

apr_status_t apr_thread_pool_create (apr_thread_pool_t **me, apr_size_t init_threads, apr_size_t max_threads, apr_pool_t *pool)
 
apr_status_t apr_thread_pool_destroy (apr_thread_pool_t *me)
 
apr_status_t apr_thread_pool_push (apr_thread_pool_t *me, apr_thread_start_t func, void *param, apr_byte_t priority, void *owner)
 
apr_status_t apr_thread_pool_schedule (apr_thread_pool_t *me, apr_thread_start_t func, void *param, apr_interval_time_t time, void *owner)
 
apr_status_t apr_thread_pool_top (apr_thread_pool_t *me, apr_thread_start_t func, void *param, apr_byte_t priority, void *owner)
 
apr_status_t apr_thread_pool_tasks_cancel (apr_thread_pool_t *me, void *owner)
 
apr_size_t apr_thread_pool_tasks_count (apr_thread_pool_t *me)
 
apr_size_t apr_thread_pool_scheduled_tasks_count (apr_thread_pool_t *me)
 
apr_size_t apr_thread_pool_threads_count (apr_thread_pool_t *me)
 
apr_size_t apr_thread_pool_busy_count (apr_thread_pool_t *me)
 
apr_size_t apr_thread_pool_idle_count (apr_thread_pool_t *me)
 
apr_size_t apr_thread_pool_idle_max_set (apr_thread_pool_t *me, apr_size_t cnt)
 
apr_size_t apr_thread_pool_tasks_run_count (apr_thread_pool_t *me)
 
apr_size_t apr_thread_pool_tasks_high_count (apr_thread_pool_t *me)
 
apr_size_t apr_thread_pool_threads_high_count (apr_thread_pool_t *me)
 
apr_size_t apr_thread_pool_threads_idle_timeout_count (apr_thread_pool_t *me)
 
apr_size_t apr_thread_pool_idle_max_get (apr_thread_pool_t *me)
 
apr_size_t apr_thread_pool_thread_max_set (apr_thread_pool_t *me, apr_size_t cnt)
 
apr_interval_time_t apr_thread_pool_idle_wait_set (apr_thread_pool_t *me, apr_interval_time_t timeout)
 
apr_interval_time_t apr_thread_pool_idle_wait_get (apr_thread_pool_t *me)
 
apr_size_t apr_thread_pool_thread_max_get (apr_thread_pool_t *me)
 
apr_size_t apr_thread_pool_threshold_set (apr_thread_pool_t *me, apr_size_t val)
 
apr_size_t apr_thread_pool_threshold_get (apr_thread_pool_t *me)
 
apr_status_t apr_thread_pool_task_owner_get (apr_thread_t *thd, void **owner)
 

Detailed Description

APR Thread Pool Library.

Remarks
This library implements a thread pool using apr_thread_t. A thread pool is a set of threads that can be created in advance or on demand until a maximum number. When a task is scheduled, the thread pool will find an idle thread to handle the task. In case all existing threads are busy and the number of tasks in the queue is higher than the adjustable threshold, the pool will try to create a new thread to serve the task if the maximum number has not been reached. Otherwise, the task will be put into a queue based on priority, which can be valued from 0 to 255, with higher values being served first. If there are tasks with the same priority, the new task might be put at the top or at the bottom - it depends on which function is used to put the task.
There may be the case where the thread pool can use up to the maximum number of threads at peak load, but having those threads idle afterwards. A maximum number of idle threads can be set so that the extra idling threads will be terminated to save system resources.