The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Allegro::Timer - Allegro Timer routines

SYNOPSIS

   use Allegro;

   sub callback { $i++; }

   $al = Allegro->new or die;

   $timer = $al->Timer(code     => \&callback,
                       interval => 0.10);

   while($i > 0) {
      print "timer was called\n";
      $timer->poll;
   }

DESCRIPTION

Allegro::Timer provides an object-oriented interface to the Allegro timer related routines.

A timer object, after created will call its callback function at a certain interval until stopped.

Currently, Timers must be polled for the callback function to be called. A thread-based or SIGALRM-based Timer implementation may be included in the future. See poll below.

METHODS

new - create new timer

Creates a new timer object. Returns an Allegro::Timer object on success, or undef on error.

   $timer = $al->Timer(code     => \&callback,
                       interval => 1.0,
                       param    => $param,
                       defer    => 0);
code - callback code reference (required)

Code reference to be called every after every interval seconds.

interval - callback interval (required)

Time (in seconds) between each timer callback.

param - parameter (optional)

Single parameter to be passed to callback function.

defer - defer timer start (optional)

If this is set, the timer will not start until the start method is called. Not set by default.

poll - updates timer

This method must be called continously to call the code specified by new.

start - starts timer

Starts the timer. This will usually be called on timer creation unless you specify to not start the timer.

stop - disables timer

Stops the timer. The timer may be started again with another call to start.

AUTHOR

Colin O'Leary <colino@cpan.org>

COPYRIGHT

Copyright 2003 by Colin O'Leary. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The Allegro library is copyright its authors, and is giftware. See http://alleg.sf.net for more information.

SEE ALSO