=pod

=head1 NAME

SDL::Time - a SDL perl extension for managing timers.

=head1 CATEGORY

Core

=head1 SYNOPSIS

	package foo;
	use threads;
	use threads::shared;

	use SDL;
	use SDL::Time;

	SDL::init(SDL_INIT_TIMER);

	my $tick :shared = 0;

	sub ticker { $tick++; warn $tick; return 100 };

	package main;

	my $id = SDL::Time::add_timer(100, 'foo::ticker');

	sleep(2);

	SDL::Time::remove_timer($id);

	SDL::quit();

=head1 METHODS


=head2 get_ticks()

This will be move to SDL::Time.


Returns the number of milliseconds since SDL library initialization. This value wraps around if the program runs for more than 49.7 days


=head2 delay(ms)

This will be move to SDL::Time.

This function waits a specified number of milliseconds before returning. It waits at least the specified time, but possible longer due to OS scheduling. The delay granularity is at least 10 ms. Some platforms have shorter clock ticks but this is the most common.
SDL::delay doesn't returns anything. 

=head2 add_timer(interval,callback)

This runs in a seperate thread and a cloned perl thread.

Adds a callback function to be run after the specified number of milliseconds has elapsed. 
The callback function is passed the current timer interval and the user supplied parameter from the SDL::add_timer call and returns the next timer interval.
If the returned value from the callback is the same as the one passed in, the timer continues at the same rate.
If the returned value from the callback is 0, the timer is cancelled.

Another way to cancel a currently-running timer is by calling SDL::remove_timer with the timer's ID (which was returned from SDL::add_timer).

The timer callback function may run in a different thread than your main program, and so shouldn't call any functions from within itself. 
However, you may always call SDL::push_event.

SDL::add_timer returns the identifier value of the generated timer or undef on error. 

Note : If you use this function, you need to pass SDL_INIT_TIMER to SDL::init. 

=head4 Parameters

	interval [in]   The desired interval of the timer, in milliseconds. 
			The granularity of the timer is platform-dependent, but you should count on it being at least 10 ms as this is the most common number.
			This means that if you request a 16 ms timer, your callback will run approximately 20 ms later on an unloaded system. 
			If you wanted to set a flag signaling a frame update at 30 frames per second (every 33 ms), you might set a timer for 30 ms (see example below). 

	callback [in]   The SDL timer callback function which is called when the specified interval elapses. 


=head2 remove_timer( id )

Removes a timer callback previously added with SDL::add_timer. 
It returns 0 on succés or -1 on error.


