blob: a10243c0f4b41c9a987d5209b122c32862fb07dd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
// SPDX-License-Identifier: LGPL-2.1-or-later
/*
* This file is part of the PCEPlib, a PCEP protocol library.
*
* Copyright (C) 2020 Volta Networks https://voltanet.io/
*
* Author : Brady Johnson <brady@voltanet.io>
*
*/
/*
* Timer definitions to be used internally by the pcep_timers library.
*/
#ifndef PCEPTIMERINTERNALS_H_
#define PCEPTIMERINTERNALS_H_
#include <stdint.h>
#include <pthread.h>
#include "pcep_utils_ordered_list.h"
/* Function pointer to be called when timers expire.
* Parameters:
* void *data - passed into create_timer
* int timer_id - the timer_id returned by create_timer
*/
typedef void (*timer_expire_handler)(void *, int);
/* Function pointer when an external timer infrastructure is used */
typedef void (*ext_timer_create)(void *infra_data, void **timer, int seconds,
void *data);
typedef void (*ext_timer_cancel)(void **timer);
typedef int (*ext_pthread_create_callback)(pthread_t *pthread_id,
const pthread_attr_t *attr,
void *(*start_routine)(void *),
void *data, const char *thread_name);
typedef struct pcep_timer_ {
time_t expire_time;
uint16_t sleep_seconds;
int timer_id;
void *data;
void *external_timer;
} pcep_timer;
typedef struct pcep_timers_context_ {
ordered_list_handle *timer_list;
bool active;
timer_expire_handler expire_handler;
pthread_t event_loop_thread;
pthread_mutex_t timer_list_lock;
void *external_timer_infra_data;
ext_timer_create timer_create_func;
ext_timer_cancel timer_cancel_func;
} pcep_timers_context;
/* functions implemented in pcep_timers_loop.c */
void *event_loop(void *context);
#endif /* PCEPTIMERINTERNALS_H_ */
|