pods::SDL::Time(3pm)
okay bestie, you're reading pods::SDL::Time(3pm) β a User Contributed Perl Documentation page β and it's all about SDL::Time, the SDL Perl extension for managing timers πβ¨
πΈ NAME πΈ
SDL::Time β An SDL Perl extension for managing timers. That's the whole vibe: timers, but make it SDL Perl β±οΈπ
π CATEGORY π
Core β that's the category, no cap. π
β¨ SYNOPSIS β¨
okay so here's the whole group-chat script, exactly as written, bestie:
use warnings;
use strict;
use threads;
use threads::shared;
use SDL::Time;
package foo;
use SDL ':all';
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);
π METHODS π
π§ add_timer π§
the signature as written is:
my $id = SDL::Timer::add_timer( $ms_interval, $callback );
okay so this one? It runs in a separate thread and a cloned Perl thread. threads and threads::shared must be used to share any variables the timer uses. literally don't skip that part, bestie π§΅β¨
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 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. π«Ά
SDL::Time::add_timer returns the identifier value of the generated timer or undef on error. π
π¨ Note: You must initialize (SDL::init) the timer subsystem to use this function.
π¦ remove_timer π¦
the signature as written is:
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 the SDL::Time::add_timer function. πͺͺ
SDL::Time::remove_timer returns 0 on success or -1 on error. π
π AUTHORS π
See "AUTHORS" in SDL. π
k bye bestie β this page is from perl v5.42.0, dated 2024-05-01, and its manual-page home is pods::SDL::Time(3pm). stay timer-chic πβ¨π
π¦ where this page comes from
- opensuse-leap 16.0: perl-SDL 2.548-bp160.1.13 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-SDL 2.548-bp160.1.13 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-SDL 2.548-bp160.1.13 Β· LGPL-2.1-or-later
- opensuse-leap 16.0: perl-SDL 2.548-bp160.1.13 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms