#ifndef __KERNEL_TIMER_H
#define __KERNEL_TIMER_H

#include <list.h>
#include <sys/types.h>

void timer_init(void);

struct timer;
typedef enum handler_return (*timer_callback)(struct timer *, time_t now, void *arg);

#define TIMER_MAGIC 'timr'

struct timer {
	int magic;
	struct list_node node;

	time_t scheduled_time;
	time_t periodic_time;

	timer_callback callback;
	void *arg;
};

void timer_initialize(struct timer *);
void timer_set_oneshot(struct timer *, time_t delay, timer_callback, void *arg);
void timer_set_periodic(struct timer *, time_t period, timer_callback, void *arg);
void timer_cancel(struct timer *);

#endif

