|struct ao2_container *||active_threads|
|The container of active threads. Active threads are those that are currently running tasks. |
|struct ast_taskprocessor *||control_tps|
|The control taskprocessor. |
|struct ao2_container *||idle_threads|
|The container of idle threads. Idle threads are those that are currenly waiting to run tasks. |
|struct ast_threadpool_listener *||listener|
|struct ast_taskprocessor *||tps|
|The main taskprocessor. |
|struct ao2_container *||zombie_threads|
|The container of zombie threads. Zombie threads may be running tasks, but they are scheduled to die soon. |
A threadpool is a collection of threads that execute tasks from a common queue.
The container of active threads. Active threads are those that are currently running tasks.
The control taskprocessor.
This is a standard taskprocessor that uses the default taskprocessor listener. In other words, all tasks queued to this taskprocessor have a single thread that executes the tasks.
All tasks that modify the state of the threadpool and all tasks that call out to threadpool listeners are pushed to this taskprocessor.
For instance, when the threadpool changes sizes, a task is put into this taskprocessor to do so. When it comes time to tell the threadpool listener that worker threads have changed state, the task is placed in this taskprocessor.
This is done for three main reasons 1) It ensures that listeners are given an accurate portrayal of the threadpool's current state. In other words, when a listener gets told a count of active, idle and zombie threads, it does not need to worry that internal state of the threadpool might be different from what it has been told. 2) It minimizes the locking required in both the threadpool and in threadpool listener's callbacks. 3) It ensures that listener callbacks are called in the same order that the threadpool had its state change.
Referenced by ast_threadpool_set_size(), ast_threadpool_shutdown(), threadpool_active_thread_idle(), threadpool_alloc(), threadpool_idle_thread_dead(), threadpool_tps_emptied(), threadpool_tps_task_pushed(), and threadpool_zombie_thread_dead().
The container of idle threads. Idle threads are those that are currenly waiting to run tasks.
Referenced by grow(), queued_active_thread_idle(), queued_idle_thread_dead(), queued_set_size(), queued_task_pushed(), shrink(), threadpool_alloc(), threadpool_send_state_changed(), and threadpool_tps_shutdown().
True if the threadpool is in the process of shutting down
Referenced by ast_threadpool_push(), ast_threadpool_set_size(), ast_threadpool_shutdown(), threadpool_active_thread_idle(), threadpool_execute(), threadpool_idle_thread_dead(), threadpool_tps_emptied(), threadpool_tps_task_pushed(), and threadpool_zombie_thread_dead().
The main taskprocessor.
Tasks that are queued in this taskprocessor are doled out to the worker threads. Worker threads that execute tasks from the threadpool are executing tasks in this taskprocessor.
The threadpool itself is actually the private data for this taskprocessor's listener. This way, as taskprocessor changes occur, the threadpool can alert its listeners appropriately.