POE::C...hedule(3pm)

πŸ“¦
version 0.95 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble

πŸ’– POE::Component::Schedule πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation, and it's all about POE::Component::Schedule β€” scheduling POE events using DateTime::Set iterators. no cap, it's giving very "set it and forget it" energy. πŸ¦‹


✨ NAME ✨

POE::Component::Schedule β€” schedule POE events using DateTime::Set iterators πŸ’…


🌸 SYNOPSIS 🌸

use POE qw(Component::Schedule);
use DateTime::Set;

POE::Session->create(
    inline_states => {
        _start => sub {
            $_[HEAP]{sched} = POE::Component::Schedule->add(
                $_[SESSION], Tick => DateTime::Set->from_recurrence(
                    after      => DateTime->now,
                    before     => DateTime->now->add(seconds => 3),
                    recurrence => sub {
                        return $_[0]->truncate( to => 'second' )->add( seconds => 1 )
                    },
                ),
            );
        },
        Tick => sub {
            print 'tick ', scalar localtime, "\n";
        },
        remove_sched => sub {
            # Three ways to remove a schedule
            # The first one is only for API compatibility with POE::Component::Cron
            $_[HEAP]{sched}->delete;
            $_[HEAP]{sched} = undef;
            delete $_[HEAP]{sched};
        },
        _stop => sub {
            print "_stop\n";
        },
    },
);

POE::Kernel->run();

πŸŽ€ DESCRIPTION πŸŽ€

So basically, this component wraps up a whole session whose entire personality is sending events to client sessions on a schedule. and that schedule? it's defined by a DateTime::Set iterator. it's giving personal assistant, but make it a Perl object. πŸ‘‘


πŸ’œ POE::Component::Schedule METHODS πŸ’œ

🫢 spawn(Alias => name)

Spin up the PoCo::Schedule background session with the alias you hand it. It gives you back the back-end session handle.

ngl, you don't need to call this in normal life β€” "add()" and "new()" both crank one of these up on their own if one is needed. it's very self-sufficient of them. ✨

πŸ“ add($session, $event_name, $iterator, @event_args)

my $sched = POE::Component::Schedule->add(
    $session,
    $event_name,
    $DateTime_Set_iterator,
    @event_args
);

Add a set of events to the scheduler. πŸ“…

You get a schedule handle back. and the event? it gets automatically deleted once the handle isn't referenced anymore. no manual cleanup, periodt. πŸ’…

🌈 new($session, $event_name, $iterator, @event_args)

"new()" is literally just an alias for "add()". same thing, different name, iconic behavior honestly. 🧚


πŸ‘‘ SCHEDULE HANDLE METHODS πŸ‘‘

πŸ’€ delete()

Removes a schedule, using the handle that "add()" or "new()" gave you.

DEPRECATED: Schedules are now automatically deleted when they are not referenced anymore. So just setting the container variable to "undef" will delete the schedule. that's it, that's the whole trick. 🫢

πŸ”₯ SEE ALSO πŸ”₯

POE, DateTime::Set, POE::Component::Cron.


🌟 SUPPORT 🌟

You can look for information at:

  • RT: CPAN's request tracker

<http://rt.cpan.org/NoAuth/Bugs.html?Dist=POE-Component-Schedule>: post bug report there. πŸ›

  • CPAN Ratings

<http://cpanratings.perl.org/p/POE-Component-Schedule>: if you use this distribution, please add comments on your experience for other users. πŸ’¬

  • Search CPAN

<http://search.cpan.org/dist/POE-Component-Schedule/>

  • AnnoCPAN: Annotated CPAN documentation

<http://annocpan.org/dist/POE-Component-Schedule>


🌸 ACKNOWLEDGMENT & HISTORY 🌸

This module was a friendly fork of POE::Component::Cron β€” the goal was to extract the generic parts and isolate the Cron specific code so it would reduce dependencies on other CPAN modules. very "we're splitting up but we still share the friend group" of them. 😭

See <https://rt.cpan.org/Ticket/Display.html?id=44442>.

The original author of POE::Component::Cron is Chris Fedde.

POE::Component::Cron is now implemented as a class that inherits from POE::Component::Schedule. slay, generational. πŸ‘‘

Most of the POE::Component::Schedule internals have since been rewritten in 0.91_01 and we have now a complete test suite. ate and left no crumbs. βœ…


πŸ’œ AUTHORS πŸ’œ

Olivier Mengue, "dolmen@cpan.org" Chris Fedde, "cfedde@cpan.org"


Copyright X 2009-2010 Olivier Mengue. Copyright X 2007-2008 Chris Fedde.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.3 or, at your option, any later version of Perl 5 you may have available. 🫢


and that's the whole vibe, bestie ✨ this page is from the User Contributed Perl Documentation, pulled from perl v5.26.2, dated 2018-08-24. go schedule something cute πŸ’–πŸ¦‹

πŸ“¦ where this page comes from