mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-30 02:26:23 +00:00
This change introduces a new API called taskpool. This is a pool of taskprocessors. It provides the following functionality: 1. Task pushing to a pool of taskprocessors 2. Synchronous tasks 3. Serializers for execution ordering of tasks 4. Growing/shrinking of number of taskprocessors in pool This functionality already exists through the combination of threadpool+taskprocessors but through investigating I determined that this carries substantial overhead for short to medium duration tasks. The threadpool uses a single queue of work, and for management of threads it involves additional tasks. I wrote taskpool to eliminate the extra overhead and management as much as possible. Instead of a single queue of work each taskprocessor has its own queue and at push time a selector chooses the taskprocessor to queue the task to. Each taskprocessor also has its own thread like normal. This spreads out the tasks immediately and reduces contention on shared resources. Using the included efficiency tests the number of tasks that can be executed per second in a taskpool is 6-12 times more than an equivalent threadpool+taskprocessor setup. Stasis has been moved over to using this new API as it is a heavy consumer of threadpool+taskprocessors and produces a lot of tasks. UpgradeNote: The threadpool_* options in stasis.conf have now been deprecated though they continue to be read and used. They have been replaced with taskpool options that give greater control over the underlying taskpool used for stasis. DeveloperNote: The taskpool API has been added for common usage of a pool of taskprocessors. It is suggested to use this API instead of the threadpool+taskprocessor approach.
66 lines
2.0 KiB
C
66 lines
2.0 KiB
C
/*
|
|
* Asterisk -- An open source telephony toolkit.
|
|
*
|
|
* Copyright (C) 2012-2013, Digium, Inc.
|
|
*
|
|
* Mark Michelson <mmmichelson@digium.com>
|
|
*
|
|
* See http://www.asterisk.org for more information about
|
|
* the Asterisk project. Please do not directly contact
|
|
* any of the maintainers of this project for assistance;
|
|
* the project provides a web site, mailing lists and IRC
|
|
* channels for your use.
|
|
*
|
|
* This program is free software, distributed under the terms of
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
* at the top of the source tree.
|
|
*/
|
|
|
|
|
|
#ifndef _ASTERISK_SERIALIZER_SHUTDOWN_GROUP_H
|
|
#define _ASTERISK_SERIALIZER_SHUTDOWN_GROUP_H
|
|
|
|
struct ast_serializer_shutdown_group;
|
|
|
|
/*!
|
|
* \brief Create a serializer group shutdown control object.
|
|
* \since 13.5.0
|
|
*
|
|
* \return ao2 object to control shutdown of a serializer group.
|
|
*/
|
|
struct ast_serializer_shutdown_group *ast_serializer_shutdown_group_alloc(void);
|
|
|
|
/*!
|
|
* \brief Wait for the serializers in the group to shutdown with timeout.
|
|
* \since 13.5.0
|
|
*
|
|
* \param shutdown_group Group shutdown controller. (Returns 0 immediately if NULL)
|
|
* \param timeout Number of seconds to wait for the serializers in the group to shutdown.
|
|
* Zero if the timeout is disabled.
|
|
*
|
|
* \return Number of serializers that did not get shutdown within the timeout.
|
|
*/
|
|
int ast_serializer_shutdown_group_join(struct ast_serializer_shutdown_group *shutdown_group, int timeout);
|
|
|
|
/*!
|
|
* \brief Increment the number of serializer members in the group.
|
|
* \since 23.1.0
|
|
* \since 22.7.0
|
|
* \since 20.17.0
|
|
*
|
|
* \param shutdown_group Group shutdown controller.
|
|
*/
|
|
void ast_serializer_shutdown_group_inc(struct ast_serializer_shutdown_group *shutdown_group);
|
|
|
|
/*!
|
|
* \brief Decrement the number of serializer members in the group.
|
|
* \since 23.1.0
|
|
* \since 22.7.0
|
|
* \since 20.17.0
|
|
*
|
|
* \param shutdown_group Group shutdown controller.
|
|
*/
|
|
void ast_serializer_shutdown_group_dec(struct ast_serializer_shutdown_group *shutdown_group);
|
|
|
|
#endif /* ASTERISK_SERIALIZER_SHUTDOWN_GROUP_H */
|