]> git.proxmox.com Git - mirror_frr.git/blob - pceplib/pcep_timer_internals.h
Merge pull request #12819 from isabelladeleon12/isis_load_config_before_lsp_gen
[mirror_frr.git] / pceplib / pcep_timer_internals.h
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /*
3 * This file is part of the PCEPlib, a PCEP protocol library.
4 *
5 * Copyright (C) 2020 Volta Networks https://voltanet.io/
6 *
7 * Author : Brady Johnson <brady@voltanet.io>
8 *
9 */
10
11 /*
12 * Timer definitions to be used internally by the pcep_timers library.
13 */
14
15 #ifndef PCEPTIMERINTERNALS_H_
16 #define PCEPTIMERINTERNALS_H_
17
18 #include <stdint.h>
19 #include <pthread.h>
20
21 #include "pcep_utils_ordered_list.h"
22
23 /* Function pointer to be called when timers expire.
24 * Parameters:
25 * void *data - passed into create_timer
26 * int timer_id - the timer_id returned by create_timer
27 */
28 typedef void (*timer_expire_handler)(void *, int);
29
30 /* Function pointer when an external timer infrastructure is used */
31 typedef void (*ext_timer_create)(void *infra_data, void **timer, int seconds,
32 void *data);
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);
38
39 typedef struct pcep_timer_ {
40 time_t expire_time;
41 uint16_t sleep_seconds;
42 int timer_id;
43 void *data;
44 void *external_timer;
45
46 } pcep_timer;
47
48 typedef struct pcep_timers_context_ {
49 ordered_list_handle *timer_list;
50 bool active;
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;
57
58 } pcep_timers_context;
59
60 /* functions implemented in pcep_timers_loop.c */
61 void *event_loop(void *context);
62
63
64 #endif /* PCEPTIMERINTERNALS_H_ */