1 // SPDX-License-Identifier: LGPL-2.1-or-later
3 * This file is part of the PCEPlib, a PCEP protocol library.
5 * Copyright (C) 2020 Volta Networks https://voltanet.io/
7 * Author : Brady Johnson <brady@voltanet.io>
12 * Timer definitions to be used internally by the pcep_timers library.
15 #ifndef PCEPTIMERINTERNALS_H_
16 #define PCEPTIMERINTERNALS_H_
21 #include "pcep_utils_ordered_list.h"
23 /* Function pointer to be called when timers expire.
25 * void *data - passed into create_timer
26 * int timer_id - the timer_id returned by create_timer
28 typedef void (*timer_expire_handler
)(void *, int);
30 /* Function pointer when an external timer infrastructure is used */
31 typedef void (*ext_timer_create
)(void *infra_data
, void **timer
, int seconds
,
33 typedef void (*ext_timer_cancel
)(void **timer
);
34 typedef int (*ext_pthread_create_callback
)(pthread_t
*pthread_id
,
35 const pthread_attr_t
*attr
,
36 void *(*start_routine
)(void *),
37 void *data
, const char *thread_name
);
39 typedef struct pcep_timer_
{
41 uint16_t sleep_seconds
;
48 typedef struct pcep_timers_context_
{
49 ordered_list_handle
*timer_list
;
51 timer_expire_handler expire_handler
;
52 pthread_t event_loop_thread
;
53 pthread_mutex_t timer_list_lock
;
54 void *external_timer_infra_data
;
55 ext_timer_create timer_create_func
;
56 ext_timer_cancel timer_cancel_func
;
58 } pcep_timers_context
;
60 /* functions implemented in pcep_timers_loop.c */
61 void *event_loop(void *context
);
64 #endif /* PCEPTIMERINTERNALS_H_ */