#include <stdio.h> 
#include <stdlib.h> 
#include <string.h>
#include <pthread.h>

#include <timer.h>
#include <config.h>

void *timer(void *context) {
	printf("HELLO WORLD %d\n", (int)context);
	
	printf("CANCEL THREAD %d : %d\n", (int)context + 2, timer_cancel((int)context + 2));
	
	return (int*)0;
}

int main (int argc, char *argv[]) {
	int timers[10];
	timer_set(int timeout, timer_handler_t handler, void *context);
	
	int n = 0;
	int i = 0;
	while(1) {
		if (n < 10) {
			printf("setting new timer\n");
			timers[n] = timer_set(10 * n, timer, (void*)n);
			n++;
			printf("done\n");
		} else if (i % 100000000 == 0) {
			printf("time left: %d\n", timer_next());
		}
		
		i++;
	}
	
	return 0;
}
