Asterisk - The Open Source Telephony Project GIT-master-ff80666
serializer.h
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2019, Sangoma Technologies Corporation
5 *
6 * Kevin Harwell <kharwell@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19#ifndef _AST_SERIALIZER_H
20#define _AST_SERIALIZER_H
21
22struct ast_threadpool;
23struct ast_taskpool;
24
25/*!
26 * Maintains a named pool of thread pooled taskprocessors. Also if configured
27 * a shutdown group can be enabled that will ensure all serializers have
28 * completed any assigned task before destruction.
29 */
31
32/*!
33 * \brief Destroy the serializer pool.
34 *
35 * Attempt to destroy the serializer pool. If a shutdown group has been enabled,
36 * and times out waiting for threads to complete, then this function will return
37 * the number of remaining threads, and the pool will not be destroyed.
38 *
39 * \param pool The pool to destroy
40 */
42
43/*!
44 * \brief Create a serializer pool.
45 *
46 * Create a serializer pool with an optional shutdown group. If a timeout greater
47 * than -1 is specified then a shutdown group is enabled on the pool.
48 *
49 * \param name The base name for the pool, and used when building taskprocessor(s)
50 * \param size The size of the pool
51 * \param threadpool The backing threadpool to use
52 * \param timeout The timeout used if using a shutdown group (-1 = disabled)
53 *
54 * \return A newly allocated serializer pool object
55 * \retval NULL on error
56 */
58 unsigned int size, struct ast_threadpool *threadpool, int timeout);
59
60/*!
61 * \brief Create a serializer pool on taskpool.
62 * \since 23.1.0
63 * \since 22.7.0
64 * \since 20.17.0
65 *
66 * Create a serializer pool with an optional shutdown group. If a timeout greater
67 * than -1 is specified then a shutdown group is enabled on the pool.
68 *
69 * \param name The base name for the pool, and used when building taskprocessor(s)
70 * \param size The size of the pool
71 * \param taskpool The backing taskpool to use
72 * \param timeout The timeout used if using a shutdown group (-1 = disabled)
73 *
74 * \return A newly allocated serializer pool object
75 * \retval NULL on error
76 */
78 unsigned int size, struct ast_taskpool *taskpool, int timeout);
79
80/*!
81 * \brief Retrieve the base name of the serializer pool.
82 *
83 * \param pool The pool object
84 *
85 * \return The base name given to the pool
86 */
87const char *ast_serializer_pool_name(const struct ast_serializer_pool *pool);
88
89/*!
90 * \brief Retrieve a serializer from the pool.
91 *
92 * \param pool The pool object
93 *
94 * \return A serializer/taskprocessor
95 */
97
98/*!
99 * \brief Set taskprocessor alert levels for the serializers in the pool.
100 *
101 * \param pool The pool to destroy
102 * \param high, low
103 *
104 * \retval 0 on success.
105 * \retval -1 on error.
106 */
107int ast_serializer_pool_set_alerts(struct ast_serializer_pool *pool, long high, long low);
108
109#endif /* _AST_SERIALIZER_H */
static const char name[]
Definition: format_mp3.c:68
struct ast_taskprocessor * ast_serializer_pool_get(struct ast_serializer_pool *pool)
Retrieve a serializer from the pool.
Definition: serializer.c:175
int ast_serializer_pool_set_alerts(struct ast_serializer_pool *pool, long high, long low)
Set taskprocessor alert levels for the serializers in the pool.
Definition: serializer.c:204
const char * ast_serializer_pool_name(const struct ast_serializer_pool *pool)
Retrieve the base name of the serializer pool.
Definition: serializer.c:170
struct ast_serializer_pool * ast_serializer_pool_create(const char *name, unsigned int size, struct ast_threadpool *threadpool, int timeout)
Create a serializer pool.
Definition: serializer.c:78
int ast_serializer_pool_destroy(struct ast_serializer_pool *pool)
Destroy the serializer pool.
Definition: serializer.c:41
struct ast_serializer_pool * ast_serializer_taskpool_create(const char *name, unsigned int size, struct ast_taskpool *taskpool, int timeout)
Create a serializer pool on taskpool.
Definition: serializer.c:124
static struct ast_threadpool * threadpool
Thread pool for observers.
Definition: sorcery.c:87
static struct ast_taskpool * taskpool
Definition: stasis.c:374
An opaque taskpool structure.
Definition: taskpool.c:62
A ast_taskprocessor structure is a singleton by name.
Definition: taskprocessor.c:69
An opaque threadpool structure.
Definition: threadpool.c:36