Asterisk - The Open Source Telephony Project  21.4.1
general.c
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2021, Sangoma Technologies Corporation
5  *
6  * Kevin Harwell <kharwell@sangoma.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 #include "asterisk.h"
20 
21 #include "asterisk/astobj2.h"
22 #include "asterisk/sched.h"
23 
24 #include "general.h"
25 
26 /*! \brief Scheduler for transaction timeouts */
27 static struct ast_sched_context *sched = NULL;
28 
29 struct ast_sched_context *aeap_sched_context(void)
30 {
31  return sched;
32 }
33 
34 void aeap_general_finalize(void)
35 {
36  if (sched) {
38  sched = NULL;
39  }
40 }
41 
42 int aeap_general_initialize(void)
43 {
44  sched = ast_sched_context_create();
45  if (!sched) {
46  ast_log(LOG_ERROR, "AEAP scheduler: unable to create context");
47  return -1;
48  }
49 
50  if (ast_sched_start_thread(sched)) {
51  ast_log(LOG_ERROR, "AEAP scheduler: unable to start thread");
52  aeap_general_finalize();
53  return -1;
54  }
55 
56  return 0;
57 }
58 
int ast_sched_start_thread(struct ast_sched_context *con)
Start a thread for processing scheduler entries.
Definition: sched.c:197
Asterisk main include file. File version handling, generic pbx functions.
Definition: sched.c:76
Scheduler Routines (derived from cheops)
struct ast_sched_context * ast_sched_context_create(void)
Create a scheduler context.
Definition: sched.c:238
void ast_sched_context_destroy(struct ast_sched_context *c)
destroys a schedule context
Definition: sched.c:271