22 #include "asterisk/serializer.h"
24 #include "asterisk/threadpool.h"
51 if (pool->shutdown_group) {
54 ast_debug(3,
"Waiting on serializers before destroying pool '%s'\n", pool->name);
56 remaining = ast_serializer_shutdown_group_join(
57 pool->shutdown_group, pool->shutdown_group_timeout);
61 ast_log(LOG_WARNING,
"'%s' serializer pool destruction timeout. "
62 "'%d' dependencies still processing.\n", pool->name, remaining);
66 ao2_ref(pool->shutdown_group, -1);
67 pool->shutdown_group = NULL;
85 pool =
ast_malloc(
sizeof(*pool) + strlen(name) + 1);
90 strcpy(pool->name, name);
93 pool->
shutdown_group = timeout > -1 ? ast_serializer_shutdown_group_alloc() : NULL;
97 for (idx = 0; idx < size; ++idx) {
103 tps = ast_threadpool_serializer_group(tps_name, threadpool, pool->
shutdown_group);
105 ast_serializer_pool_destroy(pool);
106 ast_log(LOG_ERROR,
"Pool create: unable to create named serializer '%s'\n",
112 ast_serializer_pool_destroy(pool);
113 ast_log(LOG_ERROR,
"Pool create: unable to append named serializer '%s'\n",
166 tps_queue_high = high;
167 if (tps_queue_high <= 0) {
168 ast_log(AST_LOG_WARNING,
"Invalid '%s-*' taskprocessor high water alert "
169 "trigger level '%ld'\n", pool->name, tps_queue_high);
174 if (tps_queue_low < -1 || tps_queue_high < tps_queue_low) {
175 ast_log(AST_LOG_WARNING,
"Invalid '%s-*' taskprocessor low water clear alert "
176 "level '%ld'\n", pool->name, tps_queue_low);
183 ast_log(AST_LOG_WARNING,
"Failed to set alert levels for serializer '%s'.\n",
#define AST_VECTOR_RW_INIT(vec, size)
Initialize a vector with a read/write lock.
Asterisk main include file. File version handling, generic pbx functions.
long ast_taskprocessor_size(struct ast_taskprocessor *tps)
Return the current size of the taskprocessor queue.
#define AST_VECTOR_RW_UNLOCK(vec)
Unlock vector.
#define AST_TASKPROCESSOR_HIGH_WATER_LEVEL
static pj_pool_t * pool
Global memory pool for configuration and timers.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
#define AST_VECTOR_RW_RDLOCK(vec)
Obtain read lock on vector.
const char * ast_taskprocessor_name(struct ast_taskprocessor *tps)
Return the name of the taskprocessor singleton.
int ast_taskprocessor_alert_set_levels(struct ast_taskprocessor *tps, long low_water, long high_water)
Set the high and low alert water marks of the given taskprocessor queue.
long tps_queue_high
Taskprocessor high water alert trigger level.
#define AST_TASKPROCESSOR_MAX_NAME
Suggested maximum taskprocessor name length (less null terminator).
long tps_queue_low
Taskprocessor low water clear alert level.
#define AST_VECTOR_RW_FREE(vec)
Deallocates this locked vector.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
#define ast_malloc(len)
A wrapper for malloc()
#define ast_debug(level,...)
Log a DEBUG message.
static struct ast_threadpool * threadpool
Thread pool for observers.
struct ast_serializer_shutdown_group * shutdown_group
AST_VECTOR_RW(ast_sorcery_object_wizards, struct ast_sorcery_object_wizard *)
Interface for a sorcery object type wizards.
#define AST_VECTOR_RW_WRLOCK(vec)
Obtain write lock on vector.
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
Vector container support.
An API for managing task processing threads that can be shared across modules.
int shutdown_group_timeout
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
A ast_taskprocessor structure is a singleton by name.
An opaque threadpool structure.
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
void ast_taskprocessor_name_append(char *buf, unsigned int size, const char *name)
Append the next sequence number to the given string, and copy into the buffer.