From c17a1dd3f5333da59355ecc3f8788a0396a8f72d Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Fri, 3 Mar 2017 20:36:47 -0800 Subject: Timer implementation. Operations can timeout now? --- src/core/timer.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/core/timer.h (limited to 'src/core/timer.h') diff --git a/src/core/timer.h b/src/core/timer.h new file mode 100644 index 00000000..a5bd4633 --- /dev/null +++ b/src/core/timer.h @@ -0,0 +1,33 @@ +// +// Copyright 2017 Garrett D'Amore +// +// 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; + int t_sched; +}; + +typedef struct nni_timer_node nni_timer_node; + +extern void nni_timer_schedule(nni_timer_node *); +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 -- cgit v1.2.3-70-g09d2