X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=sdlgit%2FSDL-Site.git;a=blobdiff_plain;f=pages%2FSDL-Time.html-inc;h=4fc5489157a04eac8c8788369645413c56f0c4cb;hp=5d5ff242695293c682d76bcf833b53db17b776e5;hb=801213bdc2b379a428fdebad07e9d404cec99a06;hpb=411e0b6a19b323b88847fbffe2323afe98e9f8dc diff --git a/pages/SDL-Time.html-inc b/pages/SDL-Time.html-inc index 5d5ff24..4fc5489 100644 --- a/pages/SDL-Time.html-inc +++ b/pages/SDL-Time.html-inc @@ -6,8 +6,8 @@
use threads; +use warnings; + use strict; + + use threads; use threads::shared; - use SDL ':all'; use SDL::Time; package foo; + use SDL ':all'; + SDL::init(SDL_INIT_TIMER); my $tick :shared = 0; @@ -54,12 +58,16 @@-add_timer(interval, callback)
--This runs in a separate thread and a cloned Perl thread.
-The
callback
function, specified with a string of the function's name, will be called after the milliseconds ofinterval
have elapsed. +add_timer
++-my $id = SDL::Timer::add_timer( $ms_interval, $callback ); + ++This runs in a separate thread and a cloned Perl thread. +
+threads
andthreads::shared
must be used to share any variables the timer uses.The
$callback
function, specified with a string of the function's name, will be called after the milliseconds of$interval
have elapsed. The actual delay may be longer than specified depending on the underlying OS. -The callback function is passed the current timer interval as well as theinterval
parameter and should return the next timer interval. +The callback function is passed the current timer interval as well as the$interval
parameter and should return the next timer interval. If the return value from the callback is 0, the timer is cancelled; otherwise, the timer will continue to run.The timer callback function may run in a different thread to your main program, so it shouldn't call any functions from within itself. You may call SDL::push_event, however.
@@ -67,10 +75,13 @@ You may call SDL::push_event, however.Note: You must initialize (
SDL::init
) the timer subsystem to use this function.remove_timer(id)
--The other way to cancel a timer is to use
+SDL::Time::remove_timer
on theid
of a timer. -Thisid
is the return value of theSDL::Time::remove_timer
function.remove_timer
++SDL::Timer::remove_timer( $id ); + ++The other way to cancel a timer is to use
SDL::Time::remove_timer
on the$id
of a timer. +This ID is the return value of theSDL::Time::add_timer
function.
SDL::Time::remove_timer
returns0
on success or-1
on error.