aboutsummaryrefslogtreecommitdiff
path: root/src/core/timer.h
blob: 09883e0bc2e65e3402a6f43a69782dcef0b35b76 (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
//
// Copyright 2017 Garrett D'Amore <garrett@damore.org>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
// file was obtained (LICENSE.txt).  A copy of the license may also be
// found online at https://opensource.org/licenses/MIT.
//

#ifndef CORE_TIMER_H
#define CORE_TIMER_H

#include "core/defs.h"
#include "core/list.h"

// For the sake of simplicity, we just maintain a single global timer thread.

struct nni_timer_node {
	nni_time	t_expire;
	nni_cb		t_cb;
	void *		t_arg;
	nni_list_node	t_node;
};

typedef struct nni_timer_node   nni_timer_node;

extern void nni_timer_init(nni_timer_node *, nni_cb, void *);
extern void nni_timer_fini(nni_timer_node *);
extern void nni_timer_schedule(nni_timer_node *, nni_time);
extern void nni_timer_cancel(nni_timer_node *);
extern int nni_timer_sys_init(void);
extern void nni_timer_sys_fini(void);

#endif // CORE_TIMER_H