Asterisk - The Open Source Telephony Project GIT-master-a358458
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;
23
24/*!
25 * Maintains a named pool of thread pooled taskprocessors. Also if configured
26 * a shutdown group can be enabled that will ensure all serializers have
27 * completed any assigned task before destruction.
28 */
30
31/*!
32 * \brief Destroy the serializer pool.
33 *
34 * Attempt to destroy the serializer pool. If a shutdown group has been enabled,
35 * and times out waiting for threads to complete, then this function will return
36 * the number of remaining threads, and the pool will not be destroyed.
37 *
38 * \param pool The pool to destroy
39 */
41
42/*!
43 * \brief Create a serializer pool.
44 *
45 * Create a serializer pool with an optional shutdown group. If a timeout greater
46 * than -1 is specified then a shutdown group is enabled on the pool.
47 *
48 * \param name The base name for the pool, and used when building taskprocessor(s)
49 * \param size The size of the pool
50 * \param threadpool The backing threadpool to use
51 * \param timeout The timeout used if using a shutdown group (-1 = disabled)
52 *
53 * \return A newly allocated serializer pool object
54 * \retval NULL on error
55 */
57 unsigned int size, struct ast_threadpool *threadpool, int timeout);
58
59/*!
60 * \brief Retrieve the base name of the serializer pool.
61 *
62 * \param pool The pool object
63 *
64 * \return The base name given to the pool
65 */
66const char *ast_serializer_pool_name(const struct ast_serializer_pool *pool);
67
68/*!
69 * \brief Retrieve a serializer from the pool.
70 *
71 * \param pool The pool object
72 *
73 * \return A serializer/taskprocessor
74 */
76
77/*!
78 * \brief Set taskprocessor alert levels for the serializers in the pool.
79 *
80 * \param pool The pool to destroy
81 * \param high, low
82 *
83 * \retval 0 on success.
84 * \retval -1 on error.
85 */
86int ast_serializer_pool_set_alerts(struct ast_serializer_pool *pool, long high, long low);
87
88#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:127
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:156
const char * ast_serializer_pool_name(const struct ast_serializer_pool *pool)
Retrieve the base name of the serializer pool.
Definition: serializer.c:122
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:76
int ast_serializer_pool_destroy(struct ast_serializer_pool *pool)
Destroy the serializer pool.
Definition: serializer.c:39
static struct ast_threadpool * threadpool
Thread pool for observers.
Definition: sorcery.c:86
A ast_taskprocessor structure is a singleton by name.
Definition: taskprocessor.c:69
An opaque threadpool structure.
Definition: threadpool.c:36