serializer: move/add asterisk serializer pool functionality

Serializer pools have previously existed in Asterisk. However, for the most
part the code has been duplicated across modules. This patch abstracts the
code into an 'ast_serializer_pool' object. As well the code is now centralized
in serializer.c/h.

In addition serializer pools can now optionally be monitored by a shutdown
group. This will prevent the pool from being destroyed until all serializers
have completed.

Change-Id: Ib1e906144b90ffd4d5ed9826f0b719ca9c6d2971
This commit is contained in:
Kevin Harwell
2019-10-02 11:24:21 -05:00
parent 6ef806ca60
commit afc10c25ac
5 changed files with 371 additions and 1 deletions

View File

@@ -1280,11 +1280,22 @@ unsigned int ast_taskprocessor_seq_num(void)
return (unsigned int) ast_atomic_fetchadd_int(&seq_num, +1);
}
#define SEQ_STR_SIZE (1 + 8 + 1) /* Dash plus 8 hex digits plus null terminator */
void ast_taskprocessor_name_append(char *buf, unsigned int size, const char *name)
{
int final_size = strlen(name) + SEQ_STR_SIZE;
ast_assert(buf != NULL && name != NULL);
ast_assert(final_size <= size);
snprintf(buf, final_size, "%s-%08x", name, ast_taskprocessor_seq_num());
}
void ast_taskprocessor_build_name(char *buf, unsigned int size, const char *format, ...)
{
va_list ap;
int user_size;
#define SEQ_STR_SIZE (1 + 8 + 1) /* Dash plus 8 hex digits plus null terminator */
ast_assert(buf != NULL);
ast_assert(SEQ_STR_SIZE <= size);