ast_threadpool Struct Reference

An opaque threadpool structure. More...

Collaboration diagram for ast_threadpool:

Collaboration graph
[legend]

Data Fields

struct ao2_containeractive_threads
 The container of active threads. Active threads are those that are currently running tasks.
struct ast_taskprocessorcontrol_tps
 The control taskprocessor.
struct ao2_containeridle_threads
 The container of idle threads. Idle threads are those that are currenly waiting to run tasks.
struct ast_threadpool_listenerlistener
struct ast_threadpool_options options
int shutting_down
struct ast_taskprocessortps
 The main taskprocessor.
struct ao2_containerzombie_threads
 The container of zombie threads. Zombie threads may be running tasks, but they are scheduled to die soon.

Detailed Description

An opaque threadpool structure.

A threadpool is a collection of threads that execute tasks from a common queue.

Definition at line 36 of file threadpool.c.


Field Documentation

struct ao2_container* active_threads [read]

The container of active threads. Active threads are those that are currently running tasks.

Definition at line 43 of file threadpool.c.

Referenced by activate_thread(), grow(), queued_active_thread_idle(), queued_set_size(), shrink(), threadpool_alloc(), threadpool_send_state_changed(), and threadpool_tps_shutdown().

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.

Definition at line 96 of file threadpool.c.

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().

struct ao2_container* idle_threads [read]

The container of idle threads. Idle threads are those that are currenly waiting to run tasks.

Definition at line 48 of file threadpool.c.

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().

Threadpool-specific options

Definition at line 100 of file threadpool.c.

Referenced by ast_threadpool_create(), grow(), queued_task_pushed(), threadpool_alloc(), and worker_thread_alloc().

struct ast_taskprocessor* tps [read]

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.

Definition at line 67 of file threadpool.c.

Referenced by ast_threadpool_create(), ast_threadpool_push(), ast_threadpool_shutdown(), grow(), shrink(), and threadpool_execute().

struct ao2_container* zombie_threads [read]

The container of zombie threads. Zombie threads may be running tasks, but they are scheduled to die soon.

Definition at line 53 of file threadpool.c.

Referenced by queued_zombie_thread_dead(), threadpool_alloc(), threadpool_tps_shutdown(), and zombify_threads().


The documentation for this struct was generated from the following file:

Generated on Thu Apr 16 06:35:43 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6