|
Asterisk - The Open Source Telephony Project GIT-master-4f2b068
|

Go to the source code of this file.
Data Structures | |
| struct | ast_taskpool_options |
Macros | |
| #define | AST_TASKPOOL_OPTIONS_VERSION 1 |
| #define | ast_taskpool_push(pool, task, data) __ast_taskpool_push(pool, task, data, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
| #define | ast_taskpool_push_wait(pool, task, data) __ast_taskpool_push_wait(pool, task, data, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
| #define | ast_taskpool_serializer_push_wait(pool, task, data) __ast_taskpool_serializer_push_wait(pool, task, data, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Enumerations | |
| enum | ast_taskpool_selector { AST_TASKPOOL_SELECTOR_DEFAULT = 0 , AST_TASKPOOL_SELECTOR_LEAST_FULL , AST_TASKPOOL_SELECTOR_SEQUENTIAL } |
| Selectors for choosing which taskprocessor in a pool to use. More... | |
Functions | |
| int | __ast_taskpool_push (struct ast_taskpool *pool, int(*task)(void *data), void *data, const char *file, int line, const char *function) attribute_warn_unused_result |
| Push a task to the taskpool. | |
| int | __ast_taskpool_push_wait (struct ast_taskpool *pool, int(*task)(void *data), void *data, const char *file, int line, const char *function) attribute_warn_unused_result |
| Push a task to the taskpool, and wait for completion. | |
| int | __ast_taskpool_serializer_push_wait (struct ast_taskprocessor *serializer, int(*task)(void *data), void *data, const char *file, int line, const char *function) attribute_warn_unused_result |
| Push a task to a serializer, and wait for completion. | |
| struct ast_taskpool * | ast_taskpool_create (const char *name, const struct ast_taskpool_options *options) |
| Create a new taskpool. | |
| long | ast_taskpool_queue_size (struct ast_taskpool *pool) |
| Get the current number of queued tasks in the taskpool. | |
| struct ast_taskprocessor * | ast_taskpool_serializer (const char *name, struct ast_taskpool *pool) |
| Serialized execution of tasks within a ast_taskpool. | |
| struct ast_taskprocessor * | ast_taskpool_serializer_get_current (void) |
| Get the taskpool serializer currently associated with this thread. | |
| struct ast_taskprocessor * | ast_taskpool_serializer_group (const char *name, struct ast_taskpool *pool, struct ast_serializer_shutdown_group *shutdown_group) |
| Serialized execution of tasks within a ast_taskpool. | |
| int | ast_taskpool_serializer_suspend (struct ast_taskprocessor *serializer) |
| Suspend a serializer, causing tasks to be queued until unsuspended. | |
| int | ast_taskpool_serializer_unsuspend (struct ast_taskprocessor *serializer) |
| Unsuspend a serializer, causing tasks to be executed. | |
| void | ast_taskpool_shutdown (struct ast_taskpool *pool) |
| Shut down a taskpool and remove the underlying taskprocessors. | |
| size_t | ast_taskpool_taskprocessors_count (struct ast_taskpool *pool) |
| Get the current number of taskprocessors in the taskpool. | |
API providing queued task execution across threads.
Definition in file taskpool.h.
| #define AST_TASKPOOL_OPTIONS_VERSION 1 |
Definition at line 76 of file taskpool.h.
| #define ast_taskpool_push | ( | pool, | |
| task, | |||
| data | |||
| ) | __ast_taskpool_push(pool, task, data, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Definition at line 210 of file taskpool.h.
| #define ast_taskpool_push_wait | ( | pool, | |
| task, | |||
| data | |||
| ) | __ast_taskpool_push_wait(pool, task, data, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Definition at line 230 of file taskpool.h.
| #define ast_taskpool_serializer_push_wait | ( | pool, | |
| task, | |||
| data | |||
| ) | __ast_taskpool_serializer_push_wait(pool, task, data, __FILE__, __LINE__, __PRETTY_FUNCTION__) |
Definition at line 335 of file taskpool.h.
Selectors for choosing which taskprocessor in a pool to use.
| Enumerator | |
|---|---|
| AST_TASKPOOL_SELECTOR_DEFAULT | |
| AST_TASKPOOL_SELECTOR_LEAST_FULL | |
| AST_TASKPOOL_SELECTOR_SEQUENTIAL | |
Definition at line 69 of file taskpool.h.
| int __ast_taskpool_push | ( | struct ast_taskpool * | pool, |
| int(*)(void *data) | task, | ||
| void * | data, | ||
| const char * | file, | ||
| int | line, | ||
| const char * | function | ||
| ) |
Push a task to the taskpool.
Tasks pushed into the taskpool will be automatically taken by one of the taskprocessors within
| pool | The taskpool to add the task to |
| task | The task to add |
| data | The parameter for the task |
| 0 | success |
| -1 | failure |
Definition at line 527 of file taskpool.c.
References __ast_taskprocessor_push(), ao2_bump, ao2_cleanup, ao2_lock, ao2_unlock, ast_tvnow(), ast_taskpool_options::auto_increment, ast_taskpool::dynamic_taskprocessors, NULL, ast_taskpool::options, RAII_VAR, ast_taskpool::selector, ast_taskpool::shutting_down, ast_taskpool::static_taskprocessors, task(), taskpool_dynamic_pool_grow(), and taskpool_taskprocessor::taskprocessor.
Referenced by __ast_sip_push_task(), __ast_taskpool_push_wait(), and ast_taskpool_push().
| int __ast_taskpool_push_wait | ( | struct ast_taskpool * | pool, |
| int(*)(void *data) | task, | ||
| void * | data, | ||
| const char * | file, | ||
| int | line, | ||
| const char * | function | ||
| ) |
Push a task to the taskpool, and wait for completion.
Tasks pushed into the taskpool will be automatically taken by one of the taskprocessors within
| pool | The taskpool to add the task to |
| task | The task to add |
| data | The parameter for the task |
| 0 | success |
| -1 | failure |
Definition at line 635 of file taskpool.c.
References __ast_taskpool_push(), ast_cond_wait, ast_mutex_lock, ast_mutex_unlock, ast_taskpool_get_current(), taskpool_sync_task::complete, taskpool_sync_task::cond, taskpool_sync_task::fail, taskpool_sync_task::lock, task(), taskpool_sync_task_cleanup(), and taskpool_sync_task_init().
Referenced by __ast_sip_push_task_wait(), __ast_sip_push_task_wait_serializer(), and ast_taskpool_push_wait().
| int __ast_taskpool_serializer_push_wait | ( | struct ast_taskprocessor * | serializer, |
| int(*)(void *data) | task, | ||
| void * | data, | ||
| const char * | file, | ||
| int | line, | ||
| const char * | function | ||
| ) |
Push a task to a serializer, and wait for completion.
| serializer | The serializer to add the task to |
| task | The task to add |
| data | The parameter for the task |
| 0 | success |
| -1 | failure |
Definition at line 882 of file taskpool.c.
References __ast_taskprocessor_push(), ao2_lock, ao2_object_get_lockaddr(), ao2_unlock, ast_cond_wait, ast_mutex_lock, ast_mutex_unlock, ast_taskpool_get_current(), ast_taskpool_serializer_get_current(), ast_taskprocessor_execute(), ast_taskprocessor_listener_get_user_data(), ast_taskprocessor_push, ast_taskprocessor_size(), ast_threadstorage_set_ptr(), taskpool_sync_task::complete, taskpool_sync_task::cond, serializer::cond, taskpool_sync_task::fail, listener(), taskpool_sync_task::lock, NULL, SERIALIZER_SUSPENDED, serializer::suspended, task(), taskpool_serializer_empty_task(), taskpool_sync_task_cleanup(), and taskpool_sync_task_init().
Referenced by __ast_sip_push_task_wait(), __ast_sip_push_task_wait_serializer(), and ast_taskpool_serializer_push_wait().
| struct ast_taskpool * ast_taskpool_create | ( | const char * | name, |
| const struct ast_taskpool_options * | options | ||
| ) |
Create a new taskpool.
This function creates a taskpool. Tasks may be pushed onto this task pool and will be automatically acted upon by taskprocessors within the pool.
Only a single taskpool with a given name may exist. This function will fail if a taskpool with the given name already exists.
| name | The unique name for the taskpool |
| options | The behavioral options for this taskpool |
| NULL | Failed to create the taskpool |
| non-NULL | The newly-created taskpool |
Definition at line 324 of file taskpool.c.
References ao2_alloc, ao2_bump, ao2_ref, ast_log, ast_sched_add(), AST_TASKPOOL_OPTIONS_VERSION, AST_TASKPOOL_SELECTOR_DEFAULT, AST_TASKPOOL_SELECTOR_LEAST_FULL, AST_TASKPOOL_SELECTOR_SEQUENTIAL, ast_taskpool_shutdown(), AST_VECTOR_APPEND, ast_taskpool::dynamic_taskprocessors, ast_taskpool_options::growth_threshold, ast_taskpool_options::initial_size, LOG_WARNING, ast_taskpool_options::max_size, ast_taskpool_options::minimum_size, ast_taskpool::name, name, NULL, ast_taskpool::options, options, ast_taskpool::selector, ast_taskpool::shrink_sched_id, ast_taskpool::static_taskprocessors, taskpool_dynamic_pool_shrink(), TASKPOOL_GROW_THRESHOLD, taskpool_least_full_selector(), taskpool_sequential_selector(), taskpool_taskprocessor_alloc(), taskpool_taskprocessors_init(), taskpool_taskprocessor::taskprocessor, and taskpool_taskprocessors::taskprocessors.
Referenced by ast_sorcery_init(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), handle_cli_taskpool_push_efficiency(), handle_cli_taskpool_push_serializer_efficiency(), load_module(), and stasis_init().
| long ast_taskpool_queue_size | ( | struct ast_taskpool * | pool | ) |
Get the current number of queued tasks in the taskpool.
| pool | The taskpool to query |
| The | number of queued tasks in the taskpool |
Definition at line 464 of file taskpool.c.
References ao2_lock, ao2_unlock, AST_VECTOR_CALLBACK_VOID, ast_taskpool::dynamic_taskprocessors, ast_taskpool::static_taskprocessors, TASKPOOL_QUEUE_SIZE_ADD, and taskpool_taskprocessors::taskprocessors.
Referenced by ast_sip_taskpool_queue_size().
| struct ast_taskprocessor * ast_taskpool_serializer | ( | const char * | name, |
| struct ast_taskpool * | pool | ||
| ) |
Serialized execution of tasks within a ast_taskpool.
A ast_taskprocessor with the same contract as a default taskprocessor (tasks execute serially) except instead of executing out of a dedicated thread, execution occurs in a taskprocessor from a ast_taskpool.
While it guarantees that each task will complete before executing the next, there is no guarantee as to which thread from the pool individual tasks will execute. This normally only matters if your code relies on thread specific information, such as thread locals.
Use ast_taskprocessor_unreference() to dispose of the returned ast_taskprocessor.
Only a single taskprocessor with a given name may exist. This function will fail if a taskprocessor with the given name already exists.
| name | Name of the serializer. (must be unique) |
| pool | ast_taskpool for execution. |
| NULL | on error. |
Definition at line 860 of file taskpool.c.
References ast_taskpool_serializer_group(), name, and NULL.
Referenced by AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), handle_cli_taskpool_push_serializer_efficiency(), internal_stasis_subscribe(), and sorcery_object_type_alloc().
| struct ast_taskprocessor * ast_taskpool_serializer_get_current | ( | void | ) |
Get the taskpool serializer currently associated with this thread.
| serializer | on success. |
| NULL | on error or no serializer associated with the thread. |
Definition at line 825 of file taskpool.c.
References ast_threadstorage_get_ptr().
Referenced by __ast_taskpool_serializer_push_wait(), record_serializer(), requeue_task(), rfc3326_outgoing_request(), rfc3326_outgoing_response(), serializer_efficiency_task(), and simple_task().
| struct ast_taskprocessor * ast_taskpool_serializer_group | ( | const char * | name, |
| struct ast_taskpool * | pool, | ||
| struct ast_serializer_shutdown_group * | shutdown_group | ||
| ) |
Serialized execution of tasks within a ast_taskpool.
A ast_taskprocessor with the same contract as a default taskprocessor (tasks execute serially) except instead of executing out of a dedicated thread, execution occurs in a taskprocessor from a ast_taskpool.
While it guarantees that each task will complete before executing the next, there is no guarantee as to which thread from the pool individual tasks will execute. This normally only matters if your code relies on thread specific information, such as thread locals.
Use ast_taskprocessor_unreference() to dispose of the returned ast_taskprocessor.
Only a single taskprocessor with a given name may exist. This function will fail if a taskprocessor with the given name already exists.
| name | Name of the serializer. (must be unique) |
| pool | ast_taskpool for execution. |
| shutdown_group | Group shutdown controller. (NULL if no group association) |
| NULL | on error. |
Definition at line 830 of file taskpool.c.
References ao2_ref, ast_serializer_shutdown_group_inc(), ast_taskprocessor_create_with_listener(), ast_taskprocessor_listener_alloc(), listener(), name, NULL, serializer_create(), serializer_tps_listener_callbacks, and shutdown_group.
Referenced by ast_serializer_taskpool_create(), ast_sip_create_serializer_group(), and ast_taskpool_serializer().
| int ast_taskpool_serializer_suspend | ( | struct ast_taskprocessor * | serializer | ) |
Suspend a serializer, causing tasks to be queued until unsuspended.
| serializer | The serializer to suspend |
| 0 | success |
| -1 | failure |
Definition at line 1001 of file taskpool.c.
References ao2_lock, ao2_unlock, ast_taskpool_get_current(), ast_taskpool_serializer_push_wait, ast_taskprocessor_listener_get_user_data(), listener(), SERIALIZER_SUSPENDING, SERIALIZER_UNSUSPENDED, serializer::suspended, and taskpool_serializer_suspend_task().
Referenced by ast_sip_session_suspend(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().
| int ast_taskpool_serializer_unsuspend | ( | struct ast_taskprocessor * | serializer | ) |
Unsuspend a serializer, causing tasks to be executed.
| serializer | The serializer to unsuspend |
| 0 | success |
| -1 | failure |
Definition at line 1050 of file taskpool.c.
References ao2_bump, ao2_lock, ao2_unlock, ast_cond_broadcast, ast_taskpool_get_current(), ast_taskpool_push, ast_taskprocessor_listener_get_user_data(), ast_taskprocessor_unreference(), serializer::cond, execute_tasks(), listener(), serializer::pool, SERIALIZER_SUSPENDED, SERIALIZER_UNSUSPENDED, and serializer::suspended.
Referenced by ast_sip_session_unsuspend(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), and AST_TEST_DEFINE().
| void ast_taskpool_shutdown | ( | struct ast_taskpool * | pool | ) |
Shut down a taskpool and remove the underlying taskprocessors.
| pool | The pool to shut down |
Definition at line 675 of file taskpool.c.
References ao2_lock, ao2_ref, ao2_unlock, AST_SCHED_DEL_UNREF, ast_taskpool::dynamic_taskprocessors, ast_taskpool::shrink_sched_id, ast_taskpool::shutting_down, ast_taskpool::static_taskprocessors, and taskpool_taskprocessors_cleanup().
Referenced by ast_taskpool_create(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), AST_TEST_DEFINE(), handle_cli_taskpool_push_efficiency(), handle_cli_taskpool_push_serializer_efficiency(), load_module(), sorcery_cleanup(), stasis_cleanup(), and unload_module().
| size_t ast_taskpool_taskprocessors_count | ( | struct ast_taskpool * | pool | ) |
Get the current number of taskprocessors in the taskpool.
| pool | The taskpool to query |
| The | number of taskprocessors in the taskpool |
Definition at line 451 of file taskpool.c.
References ao2_lock, ao2_unlock, AST_VECTOR_SIZE, ast_taskpool::dynamic_taskprocessors, ast_taskpool::static_taskprocessors, and taskpool_taskprocessors::taskprocessors.
Referenced by AST_TEST_DEFINE(), and AST_TEST_DEFINE().