2 * This file is part of the PCEPlib, a PCEP protocol library.
4 * Copyright (C) 2020 Volta Networks https://voltanet.io/
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * Author : Brady Johnson <brady@voltanet.io>
24 * Timer definitions to be used internally by the pcep_timers library.
27 #ifndef PCEPTIMERINTERNALS_H_
28 #define PCEPTIMERINTERNALS_H_
33 #include "pcep_utils_ordered_list.h"
35 /* Function pointer to be called when timers expire.
37 * void *data - passed into create_timer
38 * int timer_id - the timer_id returned by create_timer
40 typedef void (*timer_expire_handler
)(void *, int);
42 /* Function pointer when an external timer infrastructure is used */
43 typedef void (*ext_timer_create
)(void *infra_data
, void **timer
, int seconds
,
45 typedef void (*ext_timer_cancel
)(void **timer
);
46 typedef int (*ext_pthread_create_callback
)(pthread_t
*pthread_id
,
47 const pthread_attr_t
*attr
,
48 void *(*start_routine
)(void *),
49 void *data
, const char *thread_name
);
51 typedef struct pcep_timer_
{
53 uint16_t sleep_seconds
;
60 typedef struct pcep_timers_context_
{
61 ordered_list_handle
*timer_list
;
63 timer_expire_handler expire_handler
;
64 pthread_t event_loop_thread
;
65 pthread_mutex_t timer_list_lock
;
66 void *external_timer_infra_data
;
67 ext_timer_create timer_create_func
;
68 ext_timer_cancel timer_cancel_func
;
70 } pcep_timers_context
;
72 /* functions implemented in pcep_timers_loop.c */
73 void *event_loop(void *context
);
76 #endif /* PCEPTIMERINTERNALS_H_ */