Asterisk - The Open Source Telephony Project  18.5.0
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 <[email protected]>
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 
22 struct 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  */
29 struct ast_serializer_pool;
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  * \retval A newly allocated serializer pool object, or NULL on error
54  */
56  unsigned int size, struct ast_threadpool *threadpool, int timeout);
57 
58 /*!
59  * \brief Retrieve the base name of the serializer pool.
60  *
61  * \param pool The pool object
62  *
63  * \retval The base name given to the pool
64  */
65 const char *ast_serializer_pool_name(const struct ast_serializer_pool *pool);
66 
67 /*!
68  * \brief Retrieve a serializer from the pool.
69  *
70  * \param pool The pool object
71  *
72  * \retval A serializer/taskprocessor
73  */
75 
76 /*!
77  * \brief Set taskprocessor alert levels for the serializers in the pool.
78  *
79  * \param pool The pool to destroy
80  *
81  * \retval 0 on success, or -1 on error.
82  */
83 int ast_serializer_pool_set_alerts(struct ast_serializer_pool *pool, long high, long low);
84 
85 #endif /* _AST_SERIALIZER_H */
int ast_serializer_pool_destroy(struct ast_serializer_pool *pool)
Destroy the serializer pool.
Definition: serializer.c:39
static int timeout
Definition: cdr_mysql.c:86
static pj_pool_t * pool
Global memory pool for configuration and timers.
static struct ast_threadpool * threadpool
Thread pool for observers.
Definition: sorcery.c:86
static const char name[]
Definition: cdr_mysql.c:74
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
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
const char * ast_serializer_pool_name(const struct ast_serializer_pool *pool)
Retrieve the base name of the serializer pool.
Definition: serializer.c:122
A ast_taskprocessor structure is a singleton by name.
Definition: taskprocessor.c:69
An opaque threadpool structure.
Definition: threadpool.c:36
struct ast_taskprocessor * ast_serializer_pool_get(struct ast_serializer_pool *pool)
Retrieve a serializer from the pool.
Definition: serializer.c:127